Hello, we are Kevin and Ruben of the fifth Science and Technology of VTI Veurne. We would like to present you our project.
Parents have many problems with their children when it comes to brushing their teeth. Very often they don’t know if their children have brushed their teeth or not. Often children don't like to brush their teeth either.
Our idea is to notify parents at the time when their children brush their teeth with an email sent to their smartphone. At the same time we can make the brushing more pleasant by playing their favourite music to create an enjoyable experience. While brushing several instructions appear on the screen in order to teach the children a good brushing behaviour.
As a parent, you will always receive information about the brushing procedure.
#include <SparkFunColorLCDShield.h>
// Enter the time below in 12-hr format
#define HOURS 9 //de naam hours = de waarde 9
#define MINUTES 50
#define SECONDS 00
#define AMPM 0 // enter 0 for AM, 1 for PM
#define CLOCK_RADIUS 45 // radius of clock face
#define CLOCK_CENTER 50 // If you adjust the radius, you'll probably want to adjust this
#define H_LENGTH 25 // length of hour hand
#define M_LENGTH 35 // length of minute hand
#define S_LENGTH 43 // length of second hand
#define BACKGROUND BLACK // room for growth, adjust the background color according to daylight
#define C_COLOR RED // This is the color of the clock face, and digital clock
#define H_COLOR BLUE // hour hand color
#define M_COLOR GREEN // minute hand color
#define S_COLOR YELLOW // second hand color
//EMAIL
#include <Bridge.h>
#include <Temboo.h>
#include "TembooAccount.h" // contains Temboo account information
// as described in the footer comment below
/*** SUBSTITUTE YOUR VALUES BELOW: ***/
// Note that for additional security and reusability, you could
// use #define statements to specify these values in a .h file.
// your Gmail username, formatted as a complete email address, eg "bob.smith@gmail.com"
const String GMAIL_USER_NAME = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// your application specific password (see instructions above)
const String GMAIL_APP_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// the email address you want to send the email to, eg "jane.doe@temboo.com"
const String TO_EMAIL_ADDRESS = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// a flag to indicate whether we've tried to send the email yet or not
boolean attempted = false;
//---------------------------------------------------------------------------------------------------------------------------//
int xValue = 0;
int yValue = 0;
int zValue = 0;
unsigned long tijd_bij_start;
unsigned long tijd_nu;
boolean lusvoorwaarde;
boolean slechtgepoetst;
char Tijd[4];
//---------------------------------------------------------------------------------------------------------------------------------//
LCDShield lcd;
int hours, minutes, seconds, ampm;
int buttonPins[3] = {3, 4, 5}; //make a variabele that is an collection(array) of numbers 3,4,5 position 0 of the array = 3
//--------------------------------------------------------------------------------------------------------------------------//
void setup()
{
Serial.begin(9600);
/* Set up the button pins as inputs, set pull-up resistor */
for (int i = 0; i < 3; i++)
{
pinMode(buttonPins[i], INPUT);
digitalWrite(buttonPins[i], HIGH);
}
hours = HOURS;
minutes = MINUTES;
seconds = SECONDS;
ampm = AMPM;
/* Initialize the LCD, set the contrast, clear the screen */
lcd.init(PHILIPS);
lcd.contrast(-63);
lcd.clear(BACKGROUND);
Clockoutlines(); // Draw the clock face, this includes 12, 3, 6, 9
displayAnalogTime(hours, minutes, seconds); // Draw the clock hands
displayDigitalTime(hours, minutes, seconds, ampm); // Draw the digital clock text
//initialize buzzer and LED ant turn them of//
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(3, LOW); // turn the LED of
digitalWrite(2, LOW); // turn the Buzzer of
//set boolean to false//
boolean goedgepoest = true;
//E-mail
// for debugging, wait until a serial console is connected
delay(4000);
// while(!Serial);
Bridge.begin();
}
//--------------------------------------------------------------------------------------------------------------//
void loop()
{
//-----------------------------------------------------------------------------------------------------------//
// read the input of the accelerometer:
xValue = analogRead(A0);
yValue = analogRead(A1);
zValue = analogRead(A2);
// print out the value you read; this for debugging purpose
Serial.print("X value is: ");
Serial.println(xValue);
Serial.print("Y value is: ");
Serial.println(yValue);
Serial.print("Z value is: ");
Serial.println(zValue);
Serial.println(" ");
//------------------------------------------------------------------------------------------------------------------//
// adapt clock every second
delay(1000); //delay of 1000 ms (1 second)
seconds = seconds +1; //adapt variabele
if (seconds >= 60)
{
seconds = 0; // If seconds is 60, set it back to 0
minutes++; // and increase minutes by 1
if (minutes >= 60)
{
minutes = 0; // If minutes is 60, set it back to 0
hours++; // and increase hours by 1
if (hours == 12)
ampm ^= 1; // If it's 12 o'clock, flip ampm
if (hours >= 13)
hours = 1; // If hours is 13, set it to 1. 12-hr clock.
}
}
Clockoutlines(); //draw clock outline
displayAnalogTime(hours, minutes, seconds); //adapt analoge time
displayDigitalTime(hours, minutes, seconds, ampm); //adapt digital time
//---------------------------------------------------------------------------------------------------------------------------------------------------//
// tootbrush part
// start program when toothbrush is picked up
if(analogRead(A0) >= 600 || analogRead(A1) >= 600 || analogRead(A2) >= 600){
//reset accelerovalue's
xValue = 0;
yValue = 0;
zValue = 0;
//display text to start brushing//
lcd.clear(BACKGROUND);
lcd.setStr("Start brushing", 15, 10, C_COLOR, BACKGROUND);
lcd.setStr("?", 30, 55, C_COLOR, BACKGROUND);
lcd.setStr("To continue", 70, 23, C_COLOR, BACKGROUND);
lcd.setStr("press S2", 90, 30, C_COLOR, BACKGROUND);
//when 10sec are passed the clock comes back//
tijd_bij_start = millis(); //store current time
lusvoorwaarde = true;
while(tijd_nu < tijd_bij_start+10000 && digitalRead(buttonPins[1])){ //remain in loop while 10 sec are not passes and button s2 is not pressed
tijd_nu = millis();
}
if (tijd_nu >= tijd_bij_start+10000){ // when 10s are passed DO NOTHING
lcd.clear(BACKGROUND);
}
else // when button S2 is pressed the toothbrush instructions start
{
lcd.clear(BACKGROUND);
lcd.setStr("Welcome to ", 20, 25, C_COLOR, BACKGROUND);
lcd.setStr("your toothbrush", 60, 7, C_COLOR, BACKGROUND);
delay(3000);
//---------------------------------------------------------------------------//
lcd.clear(BACKGROUND);
for(int i = 30; i >= 0; i--)
{
lcd.setStr(itoa(i, Tijd, 10), 80, 50, C_COLOR, BACKGROUND);
lcd.setStr("seconden", 100, 30, C_COLOR, BACKGROUND);
lcd.setStr("Poets uw eerste", 20, 5, C_COLOR, BACKGROUND);
lcd.setStr("mondkwadrant", 40, 20, C_COLOR, BACKGROUND);
delay(1000);
lcd.clear(BACKGROUND);
//reset accelerovalue's
xValue = 0;
yValue = 0;
zValue = 0;
//test accelerovalue every second and remember highest values
if (xValue <= analogRead(A0)) xValue = analogRead(A0);
if (yValue <= analogRead(A0)) yValue = analogRead(A0);
if (zValue <= analogRead(A0)) zValue = analogRead(A0);
if (xValue < 400 || yValue < 400 || zValue < 400 ) {
lcd.clear(BACKGROUND);
lcd.setStr("Je kan dit", 10, 25, C_COLOR, BACKGROUND);
lcd.setStr("beter", 30, 45, C_COLOR, BACKGROUND);
lcd.setStr("Programma", 70,30, C_COLOR, BACKGROUND);
lcd.setStr("herstart", 90,35, C_COLOR, BACKGROUND);
digitalWrite(3, HIGH); // turn the LED on
digitalWrite(2, HIGH); // turn the BUZZER on
delay(2000);
digitalWrite(3, LOW); // turn the LED OF
digitalWrite(2, LOW); // turn the BUZZER OF
lcd.clear(BACKGROUND);
break;
boolean goedgepoest = false;}
}
//--------------------------------------------------------------------------------------------------------------------//
if (boolean goedgepoest = true)
{
lcd.clear(BACKGROUND);
for(int i = 30; i >= 0; i--)
{
lcd.setStr(itoa(i, Tijd, 10), 80, 50, C_COLOR, BACKGROUND);
lcd.setStr("seconden", 100, 30, C_COLOR, BACKGROUND);
lcd.setStr("Poets uw tweede", 20, 5, C_COLOR, BACKGROUND);
lcd.setStr("mondkwadrant", 40, 20, C_COLOR, BACKGROUND);
delay(1000);
lcd.clear(BACKGROUND);
//reset accelerovalue's
xValue = 0;
yValue = 0;
zValue = 0;
//test accelerovalue every second and remember highest values
if (xValue <= analogRead(A0)) xValue = analogRead(A0);
if (yValue <= analogRead(A0)) yValue = analogRead(A0);
if (zValue <= analogRead(A0)) zValue = analogRead(A0);
if (xValue < 200 || yValue < 200 || zValue < 200 ) {
lcd.clear(BACKGROUND);
lcd.setStr("Je kan dit", 10, 25, C_COLOR, BACKGROUND);
lcd.setStr("beter", 30, 45, C_COLOR, BACKGROUND);
lcd.setStr("Programma", 70,30, C_COLOR, BACKGROUND);
lcd.setStr("herstart", 90,35, C_COLOR, BACKGROUND);
digitalWrite(3, HIGH); // turn the LED on
digitalWrite(2, HIGH); // turn the BUZZER on
delay(5000);
digitalWrite(3, LOW); // turn the LED OF
digitalWrite(2, LOW); // turn the BUZZER OF
lcd.clear(BACKGROUND);
break;
boolean slechtgepoetst = true;}
}
}
//----------------------------------------------------------------------------------------------------------------------//
if (boolean goedgepoest = true)
{
lcd.clear(BACKGROUND);
for(int i = 30; i >= 0; i--)
{
lcd.setStr(itoa(i, Tijd, 10), 80, 50, C_COLOR, BACKGROUND);
lcd.setStr("seconden", 100, 30, C_COLOR, BACKGROUND);
lcd.setStr("Poets uw derde", 20, 5, C_COLOR, BACKGROUND);
lcd.setStr("mondkwadrant", 40, 20, C_COLOR, BACKGROUND);
delay(1000);
lcd.clear(BACKGROUND);
//reset accelerovalue's
xValue = 0;
yValue = 0;
zValue = 0;
//test accelerovalue every second and remember highest values
if (xValue <= analogRead(A0)) xValue = analogRead(A0);
if (yValue <= analogRead(A0)) yValue = analogRead(A0);
if (zValue <= analogRead(A0)) zValue = analogRead(A0);
if (xValue < 200 || yValue < 200 || zValue < 200 ) {
lcd.clear(BACKGROUND);
lcd.setStr("Je kan dit", 10, 25, C_COLOR, BACKGROUND);
lcd.setStr("beter", 30, 45, C_COLOR, BACKGROUND);
lcd.setStr("Programma", 70,30, C_COLOR, BACKGROUND);
lcd.setStr("herstart", 90,35, C_COLOR, BACKGROUND);
digitalWrite(3, HIGH); // turn the LED on
digitalWrite(2, HIGH); // turn the BUZZER on
delay(5000);
digitalWrite(3, LOW); // turn the LED OF
digitalWrite(2, LOW); // turn the BUZZER OF
lcd.clear(BACKGROUND);
break;
boolean goedgepoest = false;}
}
}
//---------------------------------------------------------------------------------------------------------------------------//
if (boolean goedgepoest = true)
{
lcd.clear(BACKGROUND);
for(int i = 30; i >= 0; i--)
{
lcd.setStr(itoa(i, Tijd, 10), 80, 50, C_COLOR, BACKGROUND);
lcd.setStr("seconden", 100, 30, C_COLOR, BACKGROUND);
lcd.setStr("Poets uw vierde", 20, 5, C_COLOR, BACKGROUND);
lcd.setStr("mondkwadrant", 40, 20, C_COLOR, BACKGROUND);
delay(1000);
lcd.clear(BACKGROUND);
//reset accelerovalue's
xValue = 0;
yValue = 0;
zValue = 0;
//test accelerovalue every second and remember highest values
if (xValue <= analogRead(A0)) xValue = analogRead(A0);
if (yValue <= analogRead(A0)) yValue = analogRead(A0);
if (zValue <= analogRead(A0)) zValue = analogRead(A0);
if (xValue < 200 || yValue < 200 || zValue < 200 ) { // in filmpje 450
lcd.clear(BACKGROUND);
lcd.setStr("Je kan dit", 10, 25, C_COLOR, BACKGROUND);
lcd.setStr("beter", 30, 45, C_COLOR, BACKGROUND);
lcd.setStr("Programma", 70,30, C_COLOR, BACKGROUND);
lcd.setStr("herstart", 90,35, C_COLOR, BACKGROUND);
digitalWrite(3, HIGH); // turn the LED on
digitalWrite(2, HIGH); // turn the BUZZER on
delay(5000);
digitalWrite(3, LOW); // turn the LED OF
digitalWrite(2, LOW); // turn the BUZZER OF
lcd.clear(BACKGROUND);
break;
boolean goedgepoest = false;}
}
}
//-----------------------------------------------------------------------------------------------------------------------//
if (boolean goedgepoest = true)
{
lcd.clear(BACKGROUND);
lcd.setStr("U hebt goed", 20, 17, M_COLOR, BACKGROUND);
lcd.setStr("gepoetst", 60, 33, M_COLOR, BACKGROUND);
delay(3000);
lcd.clear(BACKGROUND);
lcd.setStr("Sending", 20, 30, M_COLOR, BACKGROUND);
lcd.setStr("E-mail", 60, 35, M_COLOR, BACKGROUND);
delay(3000);
// EMAIL PART
TembooChoreo SendEmailChoreo;
SendEmailChoreo.begin();
// set Temboo account credentials
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");
// the first input is your Gmail email address.
SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
// next is your application specific password
SendEmailChoreo.addInput("Password", GMAIL_APP_PASSWORD);
// who to send the email to
SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS);
// then a subject line
SendEmailChoreo.addInput("Subject", "Notification: The inventive toothbrush");
// next comes the message body, the main content of the email
SendEmailChoreo.addInput("MessageBody", "Hey! I Just have brushed my teeth with my inventive toothbrush.");
unsigned int returnCode = SendEmailChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! Email sent!");
} else {
// a non-zero return code means there was an error
// read and print the error message
while (SendEmailChoreo.available()) {
char c = SendEmailChoreo.read();
Serial.print(c);
}
}
SendEmailChoreo.close();
lcd.clear(BACKGROUND);
lcd.setStr("Sent", 20, 45, M_COLOR, BACKGROUND);
lcd.setStr("E-mail", 60, 30, M_COLOR, BACKGROUND);
delay(3000);
lcd.clear(BACKGROUND);
}
//-----------------------------------------------------------------------------------------------------------------------//
}
}
} //void loop end
//THE END OF THE MAIN LOOP
//------------------------------------------------------------------------------------------------------------------------------------------//
//PROGROM TO DRAW ANALOG CLOCK FRAME
void Clockoutlines()
{
/* Draw the circle */
lcd.setCircle(CLOCK_CENTER, 66, CLOCK_RADIUS, C_COLOR);
/* Print 12, 3, 6, 9, a lot of arbitrary values are used here
for the coordinates. Just used trial and error to get them
into a nice position. */
lcd.setStr("12", CLOCK_CENTER - CLOCK_RADIUS, 66 - 9, C_COLOR, BACKGROUND);
lcd.setStr("3", CLOCK_CENTER - 9, 66 + CLOCK_RADIUS - 12, C_COLOR, BACKGROUND);
lcd.setStr("6", CLOCK_CENTER + CLOCK_RADIUS - 18, 66 - 4, C_COLOR, BACKGROUND);
lcd.setStr("9", CLOCK_CENTER - 9, 66 - CLOCK_RADIUS + 4, C_COLOR, BACKGROUND);
}
//----------------------------------------------------------------------------------------------------------------------------------------//
//PROGRAM TO DRAW DIGITAL TIME
void displayDigitalTime(int h, int m, int s, int ap)
{
char timeChar[12];
if (!ap)
{
sprintf(timeChar, "%.2d:%.2d:%.2d AM", h, m, s);
}
else
{
sprintf(timeChar, "%.2d:%.2d:%.2d PM", h, m, s);
}
/* Print the time on the clock */
lcd.setStr(timeChar, CLOCK_CENTER + CLOCK_RADIUS + 4, 22,
C_COLOR, BACKGROUND);
}
//----------------------------------------------------------------------------------------------------------------------------------------//
//PROGRAM TO DRAW ANALOG TIME
void displayAnalogTime(int h, int m, int s)
{
double midHours; // this will be used to slightly adjust the hour hand
static int hx, hy, mx, my, sx, sy;
/* Adjust time to shift display 90 degrees ccw
this will turn the clock the same direction as text */
h -= 3;
m -= 15;
s -= 15;
if (h <= 0)
h += 12;
if (m < 0)
m += 60;
if (s < 0)
s += 60;
/* Delete old lines: */
lcd.setLine(CLOCK_CENTER, 66, CLOCK_CENTER + sx, 66 + sy, BACKGROUND); // delete second hand
lcd.setLine(CLOCK_CENTER, 66, CLOCK_CENTER + mx, 66 + my, BACKGROUND); // delete minute hand
lcd.setLine(CLOCK_CENTER, 66, CLOCK_CENTER + hx, 66 + hy, BACKGROUND); // delete hour hand
/* Calculate and draw new lines: */
s = map(s, 0, 60, 0, 360); // map the 0-60, to "360 degrees"
sx = S_LENGTH * sin(3.14 * ((double) s) / 180); // woo trig!
sy = S_LENGTH * cos(3.14 * ((double) s) / 180); // woo trig!
lcd.setLine(CLOCK_CENTER, 66, CLOCK_CENTER + sx, 66 + sy, S_COLOR); // print second hand
m = map(m, 0, 60, 0, 360); // map the 0-60, to "360 degrees"
mx = M_LENGTH * sin(3.14 * ((double) m) / 180); // woo trig!
my = M_LENGTH * cos(3.14 * ((double) m) / 180); // woo trig!
lcd.setLine(CLOCK_CENTER, 66, CLOCK_CENTER + mx, 66 + my, M_COLOR); // print minute hand
midHours = minutes / 12; // midHours is used to set the hours hand to middling levels between whole hours
h *= 5; // Get hours and midhours to the same scale
h += midHours; // add hours and midhours
h = map(h, 0, 60, 0, 360); // map the 0-60, to "360 degrees"
hx = H_LENGTH * sin(3.14 * ((double) h) / 180); // woo trig!
hy = H_LENGTH * cos(3.14 * ((double) h) / 180); // woo trig!
lcd.setLine(CLOCK_CENTER, 66, CLOCK_CENTER + hx, 66 + hy, H_COLOR); // print hour hand
}
Comments