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.

Micro:bit PXT Code

Press the JavaScript link to see the JavaScript statements.

pins.digitalWritePin(DigitalPin.P14, 1)
basic.pause(250)
pins.digitalWritePin(DigitalPin.P14, 0)

Challenges

  1. The buzzer is pretty simple to use and integrate into other projects. Add it to any of the projects you have done so far.
  2. 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.
  3. Bump = buzz. Naturally.
  4. Morse code buzzing.
  5. 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.