Bring sounds of the extra-terrestrial to your very own home with this invention! Who knows where they come from – a UFO, or maybe an alien? Regardless, they’re great sci-fi fun.
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.
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;
int beepTone = 10; // The sound of the beeps
int beepLength = 5; // The length of the beeps
void setup() {
// put your setup code here, to run once:
pinMode(buzzer, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
tone(buzzer,random(1,beepTone * 1000),beepLength * 2);
delay(beepLength * 2);
tone(buzzer,random(1,beepTone * 1000),beepLength * 20);
delay(beepLength * 20);
}
Upload the code and test it out
Step 3
Modify the madness
Change the sound of the beeps
Like in a lot of other projects we’ve built, you are able to change the sound of the beeping noises. Take a look on line 3 where we can make the beep pitch either higher or lower:
int beepTone = 10; // The sound of the beeps
Have a play around with this value and try to find the most annoying number. Note that any number over 32 will not work, but apart from that, have fun!
Change the length of each beep
At the moment, the ‘alien’ beeping is just a fast jumble of random tones. Fancy making this jumble more hectic? Want to slow it down just a notch? Line 4 is where you can change this and set exactly how long each beep goes for.
int beepLength = 5; // The length of the beeps
In the demo program, the beep length is set to 10. If we decrease this number, our beeps will get shorter and sound more jumbled. A good number to try to test this is 1. If we increase this number, our beeps will get longer and will sound less and less like alien signals – though still equally as annoying. Another good number to try is 25.
int beepLength = 25; // The length of the beeps