-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ampel.ino
69 lines (55 loc) · 1.35 KB
/
Ampel.ino
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
#include <TaskMacro.h>
const unsigned long leuchtDauer = 2000; // Ampeltakt
bool piepflag = false; // Merker
Task piepser() // 5 mal piepsen, wenn Flag gesetzt
{
static int i = 0;
taskBegin();
while(1) // diese Schleife blockiert nicht
{
taskWaitFor(piepflag);
for(i = 0; i < 5; i++) // diese Schleife blockiert nicht
{
Serial.println(F("Piep"));
taskSwitch();
}
piepflag = false; // fertig mit piepsen
}
taskEnd();
}
Task ampel() // Ampelschaltung
{
static unsigned long i = 0; // zählt die Ampelaufrufe
i++;
taskBegin();
while(1) // diese Schleife blockiert nicht
{
// rotPhase
Serial.print(i);
Serial.println(F(" Rot an - Gelb aus - Gruen aus"));
taskPause(leuchtDauer);
// gelbPhase Type: Mit Rot
Serial.print(i);
Serial.println(F(" Rot an - Gelb an - Gruen aus"));
taskPause(leuchtDauer);
// grünPhase
Serial.print(i);
Serial.println(F(" Rot aus - Gelb aus - Gruen an"));
piepflag = true; // 5 mal piepsen
taskPause(leuchtDauer);
// gelbPhase Type: ohne Rot
Serial.print(i);
Serial.println(F(" Rot aus - Gelb an - Gruen aus"));
taskPause(leuchtDauer);
}
taskEnd();
}
void setup()
{
Serial.begin(9600);
}
void loop()
{
piepser();
ampel();
}