Repository navigation
Expand file tree
/
Copy pathVersion 1
More file actions
73 lines (66 loc) · 1.73 KB
/
Copy pathVersion 1
File metadata and controls
73 lines (66 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// set pin numbers:
const int buttonPin = 4; // the number of the pushbutton pin
const int resetbuttonPin = 3;
const int ledPin = 0; // the number of the LED pin
const int pushledPin = 1; // the number of the LED pin
const int relayPin = 2;
// variables will change:
int resetbuttonState = 0;
int buttonState = 0; // variable for reading the pushbutton status
int ledState = 0;
long timer = 1000;
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(pushledPin, OUTPUT);
pinMode(relayPin, OUTPUT);
pinMode(resetbuttonPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
resetbuttonState = digitalRead(resetbuttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
//add 15 min to timer
timer = timer + 900000;
digitalWrite(pushledPin, HIGH);
delay(250);
digitalWrite(pushledPin, LOW);
}
if (resetbuttonState == HIGH) {
//add 15 min to timer
timer = 0;
digitalWrite(pushledPin, HIGH);
delay(100);
digitalWrite(pushledPin, LOW);
delay(100);
digitalWrite(pushledPin, HIGH);
delay(100);
digitalWrite(pushledPin, LOW);
}
if (timer > 0)
{
digitalWrite(ledPin, HIGH);
digitalWrite(relayPin, HIGH);
ledState = HIGH;
}
else
{
digitalWrite(ledPin, LOW);
digitalWrite(relayPin, LOW);
ledState = LOW;
}
delay(10);
if(timer > 0)
{
timer = timer - 10;
}
else
{
timer = 0;
}
}