Serial.print("Could not parse info from the compiler, Time=\"");
Serial.print(__TIME__);
Serial.print("\", Date=\"");
Serial.print(__DATE__);
Serial.println("\"");
}
// Change sittime
Alarm.alarmRepeat(9,00,0,9amBreak);
Alarm.alarmRepeat(12,00,0,12pmBreak);
//Alarm.alarmRepeat(17,00,0, 5pmBreak); //Disabled due to overlap with the 12-5pm break time.
Alarm.alarmRepea
}
voidloop(){
// subtract the last reading:
total=total-readings[readIndex];
// read from the sensor:
readings[readIndex]=analogRead(inputPin);
// add the reading to the total:
total=total+readings[readIndex];
// advance to the next position in the array:
readIndex=readIndex+1;
// if we're at the end of the array...
if(readIndex>=numReadings){
// ...wrap around to the beginning:
readIndex=0;
}
// calculate the average:
average=total/numReadings;
// send it to the computer as ASCII digits
delay(1);// delay in between reads for stability
// sitting Detection
if(average>sensorGate&&isSitting==0){
satDownTime=now();//if the average pressure on seat is higher than the defined gate, AND isSitting is 0
Serial.println("User is now sitting");
isSitting=1;
}
if(average=<sensorGate&&isSitting==1){
satDownTime=now();//if not sitting down, change satDownTime to now (for break calc)
Serial.println("User is no longer sitting");
isSitting=0;
}
if(now()==satDownTime+maxSitTime&&isSitting==1){// if the time you sat down at, (plus the max time you can sit down at) equals now
Serial.println("ALERT: You have been sitting for the maximum allotted time, please take a break. This message will only show up once.");
}
if(now()==satDownTime+breakTime+snoozeTime&&isSitting==0){// if the time you sat up at, plus the max time you can break for) equals now
Serial.println("ALERT: You have been on break for the maxmimum allotted time, either press the snooze button for 5 more minutes, or get back to work.")
snoozeTime=0;// Reset snoozeTime back down to 0, so it doesn't keep compounding snooze Time every press.
snoozed=0;// reset to 0, so user can press snooze again.
}
// on button press, add
buttonState=digitalRead(buttonPin);
if(buttonState==HIGH&&snoozed==0&&isSitting=0){
snoozed=1;
snoozeTime=snoozebutton;
}
}
voidalert(){
// Empty because jesus christ phone alerts are too much work