Connect Crowtail-LED to P0 port of Crowtail-Base shield for Micro:bit. The hardware connections
are as follows:
Forever:
The
forever
block is a block that loops
any other command blocks inserted into it over
and over again. It starts from the top and executes
your code in order by working its way to the
bottom and then starts from the top again.
Digital write:
The
digital write
block enables
you to turn a pin on or off. There is a dropdown
option for you to choose which pin you want to
control, and it accepts a variable as the pins state.
You could use 1 as on and 0 as off. If you
prefer, you can also use Boolean states of true and false , but we will use 0 and 1 as our
standard throughout this guide.
Pause:
If you were to just turn pins on and off with the
digital write
block without a pause,
the LED would blink really, really fast. The
pause
block enables you to slow the micro:bit
down and lets you control the timing of things happening. It accepts a number or variable as
the number of milliseconds you want the micro:bit to pause. Think of this block as a stoplight
for your code!
Download the program to micro:bit to see what happens.
Just like the lights at home, can we add a switch to control the lights on and off at any
time?
Programming and note
You will see the LED blink on and off at 2 seconds interval. If it doesn’t, make
sure you have connected the LED to correctly port.
Result
9