BBC micro:bit
Beeping The Horn (PXT)
Introduction
There isn't much to this. There's a buzzer. It will play a high pitched tone whilst pin 14 is driven high. That means that you can't make your robot play a tune. Sad face. It's still has its uses though.
Programming
It's this simple.
Press the JavaScript link to see the JavaScript statements.
pins.digitalWritePin(DigitalPin.P14, 1) basic.pause(250) pins.digitalWritePin(DigitalPin.P14, 0)
Challenges
- The buzzer is pretty simple to use and integrate into other projects. Add it to any of the projects you have done so far.
- You can use the buzzer as a time indicator if you write your program around a loop with a sleep statement. Work out how to get the buzzer to do a short beep every second.
- Bump = buzz. Naturally.
- Morse code buzzing.
- Timely beeping synchronised with movements can be used to debug your programs as well as being a nice effect that you can add to a dancing robot program.