This dubious invention is sure to drive its victims absolutely bonkers, 100% guaranteed. When assembled and programmed, this will let off random beeps at random times that go for a random length. In fact, there's not really anything about this project that isn't random. Or annoying.
To wire up this project, you'll need your UNO R3 board, USB cable, buzzer and ultrasonic sensor. To connect your buzzer, slide its pins into the Arduino board as shown – the positive leg should go in PIN 11 and the negative leg should go in GND. For the ultrasonic sensor, we will only be using 4 of its 5 pins in this project. Connect its 'Vcc' pin to 5V on the board, its 'Trig' to PIN 7, 'Echo' to PIN 6, and 'GND' to GND on the Arduino.
While everything in this program is very random, there are still ways that we can control this randomness. Take a look at line 15 in the code, for example, where a random delay is set in-between the noise bursts.
What does this mean? Well, normally we set a delay like this: delay(time). The time is always in milliseconds. However, here we have random(1000, 25000) inside the brackets. Whaile this may look a bit complicated, all this code is really doing is generating a random number between 1000 and 25000, and this is how long the delay goes for.
Don't forget that all these numbers are in milliseconds, and 1000 milliseconds = 1 second. But the delay on line 15 isn't the only place where you can change this random() thing. Take a look at the rest of the code and see what you can change. . .