Parts & wiring

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. . .

What you’ll need for this project

To build this project, you will be using the following components:

Brain Board

Buzzer

How to connect the parts

The wiring for this project is very simple. All you need to do is slide the buzzer pins into the Brain Board – the positive leg should go in PIN 11 and the negative leg should go in GND.

Hover over the PLUS signs for extra tips

This is the positive leg of the buzzer. It will have a ‘+’ sign on top of it and will also be longer than the other leg.
Don’t forget to plug the board into your computer with the included USB cable.

The final program

Here’s the code we’ll be using to program this invention.
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; i < chirps; i++) {
    tone(buzzer, chirpTone * 1000, 30);
    delay(chirpDelay);
    tone(buzzer, chirpTone * 10000, 10);
    delay(chirpDelay);
  }
}

Make this more awesome

Learn how to modify the code

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.