The Amazing Annoyatron

0 of 20 lessons complete (0%)

Electronic Cricket

In this project, you’ll build one of our favourite projects – the electronic cricket. This invention is perfect for the unsuspecting brother, sister, grandparent or librarian, and great for creating a distraction!


Parts list

What you’ll need

Computer
Computer
Brain Board
Brain Board
Buzzer
Buzzer
USB Cable
USB Cable

Step 1

Let’s build this

Ticking Clock 2

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.

+ LEG11
– LEGGND

Step 2

Code some chaos

Don’t forget to select your port, like usual

Copy and paste the sample code

electronic_cricket.ino
int buzzer = 11;

int chirpTone = 5;
int chirpDelay = 20;

void setup() {
  // put your setup code here, to run once:
  pinMode(buzzer, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  chrip(5);
  delay(300);
}

void chrip(int chirps) {
  for(int i = 0; i < chirps; i++) {
    tone(buzzer, chirpTone * 1000, 30);
    delay(chirpDelay);
    tone(buzzer, chirpTone * 10000, 10);
    delay(chirpDelay);
  }
}

Upload the code and test it out


Step 3

Modify the madness

Change the sound of the chirping

While the chirping sound in this project is already, admittedly, very annoying, we can make a few tweaks to our code to try and make it even more so. Changing the sound of the chirp is one of best ways to do this, and allows us to make each chirp either higher or lower in pitch. Take a look at line 3 where the chirp tone is set:

int chirpTone = 5;

At the moment, this is set to 5. If we increase or decrease this, we will get a different sound out of our chirps. Play around with different numbers and find out which one’s most annoying – by testing them on your family members, of course!

Change the chirpiness (if that’s even a thing)

Another thing we can change in our program is something we call the ‘chirpiness’. To be honest, that’s just a random name we gave to a cool control in our program. This is set on line 4 and controls the short break in-between each chirp.

int chirpDelay = 20;

This is one of the most interesting things to play around with in this project, as different values give completely different sounds. Some good numbers to try are 5, 10, 30, 75, and 200.

int chirpDelay = 75;