# Halloween Candy Meter

For this lab, I decided to make a Halloween Candy meter that I will be needing very soon as Halloween is around the corner. My community is a very enthusiastic about trick or treating and as a result of that kids are able to amass an amazing amount of candy. This ends up being a nightmare for the parents. Many a times they accompany their kids and start nagging them to stop when candy levels get too high. The kids obviously do not enjoy this experience of being shadowed around when they are having fun trick-o-treating with their friends.

I decided to use my Arduino kit to solve this problem. I used the FSR to sense the weight of candy collected and calibrated it such that –

• it would start a blinking led when it is getting closer to a pound of candy
• it would start beeping (using the piezo) when the weight of the collected candy got to the one-pound mark (signaling that it is time to go home)

After uploading my code into the Arduino, I encased the breadboard and the Arduino in a takeout deli box with the FSR sensor facing outward towards the candy. I then put the deli box in my daughter’s Halloween Jack o Lantern candy collector. The video below illustrates that –

All I need to think about now is to put together a costume which is way more fun than nagging a toddler around on a fun trick-o-treating night!

Components – FSR, LED and Piezo

Code:

/*
* ——–
*
*
* Created 24 October 2006
* copyleft 2006 Tod E. Kurt &lt;tod@todbot.com
* http://todbot.com/
*/

int fsrPin = 0; // select the input pin for the potentiometer
int speakerPin = 7;
int ledPin = 13;

int val = 0;

void setup() {
pinMode(speakerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}

void loop() {

digitalWrite(speakerPin, LOW);

val = fsrReading*2; // process the value a little
//val = val/2; // process the value a little

Serial.println(” – No pressure”);
} else if (fsrReading < 100) {
Serial.println(” – Light squeeze”);
digitalWrite(ledPin, HIGH); // turn the LED on pin 13 on (HIGH is the voltage level)
delay(100); // wait for a second
digitalWrite(ledPin, LOW); // turn the LED on pin 13 off by making the voltage LOW
delay(100);
} else if (fsrReading < 400) {
Serial.println(” – Medium squeeze”);
} else {
Serial.println(” – Big squeeze”);
for( int i=0; i<500; i++ ) { // play it for 50 cycles
digitalWrite(speakerPin, HIGH);
delayMicroseconds(val);
digitalWrite(speakerPin, LOW);
delayMicroseconds(val);
}

}

}