Band 5 · Simon Says
Practice The siren
Band 2's fade, heard instead of seen. Then finding out why even steps in the number are not even steps in the sound.
Sketches for this project
Every file opens with a plain-English header saying what it does and how to wire it, hole by hole.
A siren that sounds like a siren
Sweep the note up, then sweep it back down, over and over. Two loops and one buzzer.
You have written this before without knowing it. Band 2's fade is the same program. A for loop walks a number from low to high, and something changes as it goes. There the something was brightness. Here it is pitch.
This one needs the passive buzzer
The kind with a small green circuit board visible underneath, not the sealed black one. An active buzzer has its own note built in and will simply beep at you no matter what number you give it, which makes a sweep impossible.
Run id_01_which_buzzer.ino from Which part have I got? if you are not sure. It takes ten minutes and it answers this for the rest of the course.
Build it, then find out why it sounds wrong
20 mina, so use that one.Two wires, not one. The buzzer's wire reaches the rail, and a second wire runs from that same rail to a GND pin. A rail with nothing feeding it is dead metal, and this is the wire people leave out when a build looks too simple to check.
Write it yourself. A for loop from a low number up to a high one, calling tone with the loop's number, and a short delay inside so each step is audible. Then a second loop going back down.
Start with 200 up to 2000, in steps of 10, with 5 thousandths of a second on each. Get that running before you change anything.
That is 181 steps, so about nine tenths of a second up and the same back. Before you read on, work out how much of that nine tenths is spent between 200 and 400, and how much between 1000 and 2000. The answer is the whole of the next section.
Why, and it is the same reason as the lamp
Your ear does not hear in even steps any more than your eye sees in them. Going from 200 to 400 sounds like a big change. Going from 1800 to 2000 barely sounds like a change at all, even though both are 200.
What your ear notices is doubling. 200 to 400 is a doubling and so is 1000 to 2000, and those two sound like the same size of jump. That is what a musician means by an octave, and Band 5 Part 2 said the same thing about 262 and 523.
Now do the counting. 200 to 400 is twenty steps, so a tenth of a second. 1000 to 2000 is a hundred steps, so half a second. Both are one octave, and one takes five times as long as the other. That is why it flies through the bottom and drags at the top.
So even steps in the number are not even steps in the sound. This is exactly what the dimmable lamp taught you about brightness, and the Bench lesson on Ohm's law taught you about resistors. Three different places, same fact about you.
Two ways further
- Bronze
- Make two sirens with the same code and different numbers: one that sounds urgent, and one you would be willing to have in the room for an hour. Play both to somebody and ask which is which without telling them. Write down what actually made the difference, because it is probably not what you expected.
- Silver
- Put the knob on it, so the knob sets how fast the sweep goes. Then notice that the siren stops responding to the knob during a sweep, because
delayis in the way. That is the whole of Band 5 Part 7 in one annoying observation, and fixing it withmillisis genuinely hard here. Try it and say what made it hard.
Keep
- Your first version's numbers and what it sounded like, in words
- Which of the two fixes you chose, and why
- One sentence linking this to the dimmable lamp, if you built that one
Ship it
This one is yours. Nobody handed you a sketch for it, so the code in your video is code you wrote. Say that in the post, because it is the difference between somebody who can follow a tutorial and somebody who can build a thing, and it is the difference an employer is looking for.
The four shots as usual, and make the fourth one count: the check this page asked you to run, or the version that did not work first. Put a line of your own code on screen for three seconds. Almost nobody does, and it is the most convincing three seconds in the video.
Show your work has the template. Tag it #BozomaBuilds.