-
Notifications
You must be signed in to change notification settings - Fork 0
/
Updated working i think ?
74 lines (69 loc) · 1.79 KB
/
Updated working i think ?
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
74
int pirsensor = 0;
unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period = 3000; //3 sek
const unsigned long hold = 6000; //6 sek
int check = 1;
void setup()
{
Serial.begin(9600);
startMillis = millis(); //Startar tíd?
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(2, INPUT);
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
}
void loop()
{
if (digitalRead(2) == HIGH && check == 1)
{
currentMillis = millis(); //Hvussi leingi hevur programmi koyrt
digitalWrite(12, HIGH);
digitalWrite(11, LOW);
check = 2;
}
if (currentMillis + period < millis() && check == 2)
{
currentMillis = millis(); //Hvussi leingi hevur programmi koyrt
digitalWrite(12, LOW);
digitalWrite(11, LOW);
startMillis = millis();
check = 3;
}
if (digitalRead(2) == LOW && currentMillis + period < millis() && check == 3)
{
check = 1;
currentMillis = millis(); //Hvussi leingi hevur programmi koyrt
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
startMillis = millis();
check = 4;
}
if (currentMillis + period < millis() && check == 4 )
{
currentMillis = millis(); //Hvussi leingi hevur programmi koyrt
digitalWrite(12, LOW);
digitalWrite(11, LOW);
startMillis = millis();
check = 1;
}
if (digitalRead(2) == HIGH && check == 5)
{
currentMillis = millis(); //Hvussi leingi hevur programmi koyrt
digitalWrite(12, HIGH);
digitalWrite(11, LOW);
check = 6;
currentMillis = millis();
}
if (millis() - currentMillis + period > millis() && check == 6)
{
currentMillis = millis(); //Hvussi leingi hevur programmi koyrt
digitalWrite(12, LOW);
digitalWrite(11, LOW);
startMillis = millis();
check = 1;
}
}