VMM501
V. 01 – 17/01/2019
24
©Velleman nv
5.
Within
forever
, set the
digital read pin
to
P1
. Set the
mathematical
function equal
to 0.
In reality, this is the scheme. The pull-up resistor must not be added as
hardware onto the breadboard. The pull-up function is programmed (see
step 3-4) in the code and replaces the need of the resistor on the
breadboard.
6.
Once the switch is pressed, set high voltage to P0. Set value 0 to 1 (5 V).
The motor starts running.
7.
Once the switch is released, set low voltage to P0. Set value to 0. The
motor stops running.
8.
When complete, we compile the programme and generate a hex. file. Click
on the download button and save the hex. file to the Downloads folder
C:\downloads. This hex. file is ready to upload to the micro:bit.
Plug the micro:bit into a USB port. The, drag and drop the hex. file onto the
micro:bit removable device to upload the programme.
Press the switch to run the motor and release it to stop. Now, how would you use a trimpot to control the motor
speed?
Note: Since the micro:bit voltage is 3.3 V only, it may not be enough to support the fan. To make the fan run,
you may have to rotate the blade to help it start.
5.11
Rainbow LED
1x micro:bit board
1x micro:bit breadboard adapter
1x breadboard
1x RGB LED ring
We are going to drive eight RGB LEDs in a ring and realize a
gradual rainbow.
Place the necessary components on the breadboard as shown.