Class Activity#
Week 6
Create a Script That:#
Reads laser ping sensor data in centimeters and assigns it to a variable (e.g.,
distance
); please note the sensor is connected to pin 15.Prints distance in centimeters in the terminal with its unit (e.g.,
distance: 10 cm
).Makes decisions based on the distance:
No. |
Conditions |
Do |
---|---|---|
1 |
If |
Nothing (speaker is OFF) |
& Print( |
||
2 |
If |
Play a sound (e.g., |
& Print( |
||
3 |
If |
Play a sound (e.g., |
& Print( |
Additional Instructions:#
Download
techloop.wav
from Canvas, or you can download a sound from this library: Sound LibraryPaste the music files (
.wav
) onto the SD card of the activity board.
Sample Code to Play Music#
Resource: Play Music