Tooth Monster from Kristina Colleen on Vimeo.
The Tooth Monster is a great way for parents to encourage kids to properly brush their teeth for two minutes and then to always floss when your done. We also created an incentive by dispensing a little treat after the Tooth Monster knows that you've already flossed your teeth! The mechanism works so that when you pull out the toothbrush to brush your teeth, a melody will play to indicate the start of two minutes. At two minutes, the second melody notifies the child that they can now put their toothbrush back in the holder. Doing so then triggers the dispensing of the floss, which the child puts it into a container when he/she's done. When the container's lid is opened, this finally triggers the dispensing of the coin as a little reward for his/her hard work :)
Links/Resources:
http://www.arduino.cc/en/Tutorial/Melody
http://playground.arduino.cc/Learning/SingleServoExample
http://arduino.cc/en/Tutorial/Tone2
http://www.adafruit.com/blog/2009/05/19/piezo-with-an-arduino-photoresistor/
Final Code for our Tooth Monster:
#include <Servo.h>
#include "pitches.h"
//servo
Servo myservo;
int posNeut = 100;
int posFloss = 150;
int posCoin = 60;
//this is for the speaker
int lightPin = 0;
int lightPin2 = 1;
int brushlight = 0;
int flosslight = 0;
int piezoPin = 8;
int brushthresh = 175;
int flossthresh = 200;
// notes in the melody:
int length = 15; // the number of notes
int melody[] = {
NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
int noteDurations[] = {
4, 8, 8, 4,4,4,4,4 };
int tempo = 300; // this set up is for the
void setup()
{
pinMode(piezoPin, OUTPUT);
Serial.begin(9600);
myservo.attach(10);
Serial.begin(9600);
//for
}
void loop ()
{
myservo.write(posNeut);
brushlight = analogRead(lightPin);
Serial.println("brushlight");
Serial.print(brushlight);
if (brushlight >= brushthresh)
{ // toothbrush taken out
for (int thisNote = 0; thisNote < 8; thisNote++)
{
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
}
delay (3000); //brushing teeth
for (int thisNote = 0; thisNote < 8; thisNote++)
{
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
}
brushlight = analogRead(lightPin);
Serial.println("brushlight");
Serial.print(brushlight);
while (brushlight >= brushthresh) //checks as long as toothbrush is out
{
brushlight = analogRead(lightPin);
Serial.println("brushlight read til covered");
Serial.print(brushlight);
delay(1000);
}
// at this point, toothbrush is put back
myservo.write(posFloss); //dispense floss
delay(1000); //pause
myservo.write(posNeut); //return to neutral position
delay(1000); //pause
flosslight = analogRead(lightPin2);
Serial.println("flosslight");
Serial.print(flosslight); //reading floss light
while (flosslight < flossthresh) //container covered,
{
flosslight = analogRead(lightPin2);
Serial.println("flosslight read til uncovered");
Serial.print(flosslight);
delay(1000);
}
// container is now opened
myservo.write(posCoin); //dispense coin
delay(1000); //pause
myservo.write(posNeut); //return to neutral position
delay(1000); //pause
}//if
}//void
The inside Mechanism:
No comments:
Post a Comment