Coding
-
From the Imports menu within the Basic menu, select and drag a
from microbit import *
block to the code area and attach it to the# start code here
block. -
From Loops within the Basic menu, select and drag a
while True:
block to the code area and attach it under thefrom microbit import *
block. -
From the Pins menu, select and drag a
pin0.write_digital(0)
block to the code area and attach it within thewhile True:
block. -
Change the 2nd 0 within the
pin0.write_digital
block and type 1. -
From Statements within the Basic menu, select and drag a
sleep (1000)
block to the code area and attach it underpin0.write_digital(1)
block.
Your code should look like this:
-
Right-click on
pin0.write_digital(1)
block and select duplicate attach the duplicated block undersleep (1000)
block. Change the 0 to 1. -
Right-click on
sleep (1000)
and select duplicate attach the duplicated block under thepin1.write_digital(1)
block.
-
Right-click on the
pin0.write_digital(1)
and select duplicate attach the duplicated block undersleep (1000)
. Change 1 to 0. -
Right-click on
pin1.write_digital(1)
and select duplicate attach the duplicated block underpin0.write_digital(0)
block. Change the 2nd 1 to 0. -
Right-click on
pin1.write_digital(1)
block and select duplicate attach the duplicated block underpin1.write_digital(0)
block. Change the 1st 1 to 2. -
Right Click on
sleep (1000)
and select duplicate attach the duplicated block underpin2.write_digital(1)
.
-
Right-click on
pin2.write_digital(1)
and select duplicate attach the duplicated block undersleep (1000)
. Change the 1 to 0. -
Right-click on
pin1.write_digital(1)
block and select duplicate attach the duplicated block underpin2.write_digital(0)
block. -
Right-click on
sleep (1000)
and select duplicate attach the duplicated block underpin1.write_digital(1)
block. -
Right-click on
pin1.write_digital(0)
block and select duplicate attach the duplicated block under thesleep (1000)
block.
Completed code:
Lets move on and download our code to the micro:bit.