Note:
Do not use it in a truly dangerous area, it can be dangerous!
On start:
Different from
forever
block that loops your code forever, The
On start
block
is a block of code that only runs once at the very beginning of your program. In this case, we
use it to set the melody to play once.
Download the program to micro:bit to see what happens.
The touch sensor can detect the human touch by sensing changes in
capacitance. When it detects a touch, it outputs a HIGH logic level signal.
Based on the touch IC TTP223-B, this module can detect human finger in
0~3mm, that is, you can place this sensor on a non-metallic surface such as
the glass or paper, with a thickness of less than 3MM, this would be useful for
applications that waterproof is needed, or you want to keep the buttons
secret.
There are so many dangerous areas that we can’t touch with our hands directly, otherwise, we
may be in danger. For example, we can't touch the power socket with our hands because the
danger of electric shock! Therefore, this time we will make a touch alarm, put this alarm in a
simulated danger area, and when someone touches it, make the buzzer shout loudly so that
they will never touch this area again!
Learn how the touch sensor work and use it to make a touch alarm with buzzer.
Micro:bit x1
Crowtail-Base shield for Micro:bit x1
Crowtail-Touch Sensorx1
Crowtail-Buzzer x1
Crowtail-Cable x2
USB cable x1
Target
Experiment 4 – Do not touch
Instruction
Hardware learning and connection
Required Parts
Once you upload the program to micro:bit, you can hear the buzzer playing
the “dadadum” melody once and then stop.
Result
How to make a buzzer play multiple melodies and control the previous and next song
by pressing a button?
13