const int clockRead = 1; const int clockSend = 11; const int coffee = 4; boolean first; void setup() { Serial.begin(9600); pinMode(A1, INPUT); pinMode(11, OUTPUT); pinMode(4, OUTPUT); first = true; } void loop() { if (analogRead(clockRead) == 0) { if (first == true) { brewCoffee(); } else { ringAlarm(500); } } else { if (first == false) { first = true; } digitalWrite(clockSend, LOW); Serial.println(analogRead(clockRead)); Serial.println("sleeping"); } delay(100); } void brewCoffee() { //brew the coffee (power the relay) and print a message digitalWrite(coffee, HIGH); Serial.println("making coffee!"); delay(60000); digitalWrite(coffee, LOW); Serial.println("done making coffee."); first = false; } void ringAlarm(int del) { //ring the bell (power the motor) and print a message Serial.println(analogRead(clockRead)); if (analogRead(clockRead) == 0) { digitalWrite(clockSend, HIGH); delay(del); Serial.println("alarmRinging"); } }