Little Bird Curriculum / code littlebird.com.au
_07_Buzzer1.ino Arduino (C/C++) 10 lines · 5 views ✦ Open in English IDE Raw Download Embed view

Beep the ThinkerShield's piezo buzzer (D3) with the tone(pin, frequency, duration) command.

From the unit Crack the Code · activity PRP 4: Digital output — Buzzer
int buzzerPin = 3;        // the piezo buzzer is on pin D3 of the ThinkerShield

void setup() {
  pinMode(buzzerPin, OUTPUT);   // the buzzer pin is an output
}

void loop() {
  tone(buzzerPin, 600, 30);     // play a 600 Hz tone for 30 ms...
  delay(150);                   // ...then wait 150 ms before repeating
}

Embed this snippet

As an iframe:

Or drop it inline with a script tag (injects the highlighted block where included):

Shared from Little Bird Electronics curriculum.

Copied to clipboard