Your machines can shine. Today they learn to sing, beep and wail. The neighbours may comment.
Enter the access code from the card inside your Beginner Kit (or from your GAMERIFT order email). Your name appears on every page and printout as the licensee.
Don't have a kit yet? Get the Beginner Kit, the code ships inside. Lost your code? Contact us with your order number.
Every sound you have ever heard is air wiggling. Wiggle it 440 times a second and you hear the note A. Wiggle it faster, the note rises. Your kit has two little speakers called buzzers, and your board can wiggle them at any speed you ask. Which means today you build a siren, then program an actual melody, note by note, and finish with a machine that plays it on demand.
Time: 45–60 minutes · Difficulty: 2/5 · You need: Lesson 03 done (buttons).
Your kit has an active buzzer and a passive buzzer. The active one has its own tiny musician inside: give it power and it plays its one note, forever, like a doorbell. The passive one is an empty instrument: silent until you wiggle it, but able to play any note. Tell them apart: the active one usually has a sticker on top and a sealed back; the passive one has an open green circuit board underneath. If it beeps the moment you power it, it is the active one.
tone(pin, frequency) wiggles a pin at any speed you choose, 440 for A, 262 for middle C, 1000 for a classic beep. noTone(pin) stops it. One rule: the board has one singing voice, it can only play one tone at a time. Chords are for Lesson 13, which does not exist, so improvise with rhythm instead.
Unplug the USB. Start with the passive buzzer (the open-back one), it is today's star. Buzzers have a + marking on top; the + leg is often longer too.
| From | To | Why |
|---|---|---|
| R3 pin 8 | Passive buzzer + leg | The wiggle wire |
| Passive buzzer − leg | R3 GND | Loop complete |
| R3 pin 4 | Button leg · other leg to GND | The play button, like Lesson 03 |
// GAMERIFT Beginner Kit, Lesson 08: Make Some Noise // Part 1: the classic rising-falling siren. const int buzzerPin = 8; void setup() { } void loop() { for (int f = 400; f < 1200; f = f + 10) { // pitch climbs... tone(buzzerPin, f); delay(5); } for (int f = 1200; f > 400; f = f - 10) { // ...and falls tone(buzzerPin, f); delay(5); } }
Upload. Siren. Enjoy it for exactly as long as your family allows. Now the real music, replace everything with:
// Part 2: a melody, note by note, on the button. const int buzzerPin = 8; const int buttonPin = 4; // Frequencies for one octave (C D E F G A B C) const int notes[8] = {262, 294, 330, 349, 392, 440, 494, 523}; // A tune as positions in the scale: change these and you change the song! const int tune[] = {0, 0, 4, 4, 5, 5, 4}; const int beats[] = {1, 1, 1, 1, 1, 1, 2}; const int tuneLength = 7; void setup() { pinMode(buttonPin, INPUT_PULLUP); } void loop() { if (digitalRead(buttonPin) == LOW) { // pressed: play! for (int i = 0; i < tuneLength; i++) { tone(buzzerPin, notes[tune[i]]); // look up the note delay(300 * beats[i]); // hold it for its beats noTone(buzzerPin); // tiny gap between notes delay(40); } } }
tune[] and press again. You are composing.Record your composition for your lesson log (sound on, obviously). Stuck? Contact us with a photo and we will listen for the problem.
Lights, numbers, sound, all outputs. Next lesson you meet your most grown-up sensor yet: one that measures the temperature and humidity of the actual air in your actual room, and reports it in real units.