We have completed a basic set up of our arduino and code to simulate what our final project would be. First is the pseudo code which maps out our chair experience. Then we created the actual code which works so that when the photosensor is covered for 3 seconds a sound plays for 4 seconds. In our actual project the 3 seconds would be 1 hour (someone sitting) and the 4 seconds would be 5 minutes (someone taking a break). From here we have to complete our code to account for "if" statements. For example, if someone covered the photosensor for a half hour and then got up for a quick moment, we need to make sure the arduino doesn't reset itself.
Pseudo Code
if sit= false
{check light
set sit=true
}
if sit=true
start millis
check if millis>1hour
then beep for 3 mins
reset
Actual Code
boolean sit = false;
int photocellPin = 0;
int photocellReading;
int sitThreshold = 500;
int sitStart = 3000;
long sitLimit = 3000;
void setup() {
}
void loop() {
if (sit == false) {
photocellReading = analogRead(photocellPin);
if (photocellReading < sitThreshold) {
sit = true;
sitStart = millis();
}
}
if ((sit == true) && ((millis() - sitStart) > sitLimit)) {
tone(8, 300, 1000);
sit = false;
}
}
Arduino Set Up
We will have to find or soder longer wires in our final product to acommodate for the shape of the chair. We plan to place the photosensor on the seat of the chair and put the speaker on the back of the chair.
Chair!!
We realize that the aesthetics of this chair are not pleasing to the eye and therefor we will find some fun fabric to cover it with! The best thing about this chair is that it's extremely comfortable and spinny, definitely the kind of chair someone could spend over an hour in and need to be reminded to take a break.
No comments:
Post a Comment