You know what music is, right? Well, we can guarantee that this is NOT it. We don’t want to spoil the surprise, but this one’s really, really annoying.
Parts list
What you’ll need
Step 1
Let’s build this
This is the positive leg of the buzzer. It will have a ‘+’ over top and will also be longer than the other leg.
Don’t forget to plug the board into your computer with the supplied USB cable.
Connections
Buzzer
The +LEG is the longer leg.
Step 2
Code some chaos
Don’t forget to select your port, like usual
Copy and paste the sample code
int buzzer = 11;
void setup() {
// put your setup code here, to run once:
pinMode(buzzer, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(buzzer, random(2));
delay(1);
}
Upload the code and test it out
Step 3
Modify the madness
Fiddle with the noise
The code for this invention is short, but that’s a good thing. All the code does is randomly sets the buzzer to either off or on every 1 millisecond.
delay(1);
That’s what causes the racket you heard after you uploaded the code – it’s known as ‘white noise’.
Change the delay in line 11 to alter the sound of the noise. You can’t create a delay smaller than 1 millisecond, so you’ll have to try larger values.
delay(10);