1.
Drag and drop the code blocks to form the code as shown.
You can find the
blocks in
from MICROBIT...EVT_FALL/RISE blocks in
Drawer.
2.
Set the events type on edge. Set the pull pin to
3.
Now, make a fall event block. Drag and drop the on event from
MICROBIT...EVT°FALL block below the
arrow and select the MICROBIT_ID_IO_P0 option in the pull-down menu.
Click on the second arrow and select the MICROBIT_PIN_EVENT_FALL
option in the pull-down menu.
Drag and drop the
Set pin P0 to P2 and set 0 to 1. You can find the
block in
4.
Do the same for the second event block. Instead, click on the second arrow
and select the MICROBIT_PIN_EVENT_RISE option in the pull-down
menu. Also, set pin P0 to P2 of the
the value to 0.
5.
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 down the self-locking switch and the LED will switch on. Press again to switch off the LED. Now, how
would you control the micro:bit display with this self-locking switch?
5.7
Temperature Sensor
1x micro:bit board
1x micro:bit breadboard adapter
1x breadboard
1x TMP36 temperature sensor
We are going to read out the ambient temperature (data) of
the analogue temperature sensor and display the data to the
micro:bit.
Place the necessary components on the breadboard as shown.
V. 01 – 17/01/2019
VMM501
set pin P0 to emit edge events
Pins
More
in the Code Drawer. You can find the on event
digital write pin P0 to 0
Pins
in the Code Drawer.
16
and
set pull P0 to up
Control
in the Code
P0
and to up.
on start
block. Click on the first
block into the event block.
digital write pin P0 to 0
digital write pin P0 to 0
block and set
©Velleman nv