Parts & wiring

This invention is a little bit of a step up from the original curiosity killer. In this project, the ‘victim’ is required to press the touch sensor 5000 times, before they get a long beep and need to start all over again.

Like with the curiosity killer, you can download the free ‘Press this button’ poster from EduKits using the link to the project above. The poster is great for luring in curious minds.

What you’ll need for this project

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

Brain Board

Buzzer

Touch Sensor

3 x Wires

How to connect the parts

To wire up this project, you’ll need the Brain Board, USB cable, buzzer and touch sensor. To connect your buzzer, slide its pins into the board as shown – the positive leg should go in PIN 11 and the negative leg should go in GND. For the touch sensor, attach the VCC and GND pins to the respective ones on the board, and SIG to PIN 3.

Hover over the PLUS signs for extra tips

Curiosity Killer
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 touch sensor is like a button, except that you only have to touch it lightly.

The final program

Here’s the code we’ll be using to program this invention.
int touchSensor = 3;
int buzzer = 11;
int beepLength = 5;
int count = 0;

void setup() {
  pinMode(buzzer, OUTPUT);
  pinMode(touchSensor, INPUT);
}

void loop() {
    if(count != 5000) {
    if(digitalRead(touchSensor)==HIGH)
     { 
      digitalWrite(buzzer, HIGH);
      delay(beepLength);
      digitalWrite(buzzer, LOW);
      while(digitalRead(touchSensor)==HIGH){
      }
      count++;
     }
    else
     {
      digitalWrite(buzzer, LOW);
     }
   } else {
    delay(500);
    tone(buzzer, 2000, 1000);
    while(true);
   }
}

Make this more awesome

Learn how to modify the code

Change how many times you have to press this button

5000 presses is a lot if you just want to see what happens when you get to 5000! But never fear, we can change that in the code (you were expecting that, weren’t you). Line 12 is where all the magic happens.

if(count != 5000) {

Change the number 5000 to whatever you like – this controls exactly how many times you have to press the button before you get some satisfaction out of this invention. And that satisfaction is just a slightly longer beep.

Change the beep length

Another thing we can have a fiddle with is the length of the beeps that happen when you press the button once. At the moment, they are very short – just 5 milliseconds in length. Being so short, they almost sound like clicking or tapping.

int beepLength = 5;

On line 3, we can change this. If you want each beep to go for a little longer, try 100 milliseconds, which makes the beeps sound more like beeps.

int beepLength = 100;