-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsemaforo.c++
73 lines (51 loc) · 1.27 KB
/
semaforo.c++
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
// C++ code
//
int buttonPin = 2;
int vermelhoPin =11;
int amareloPin = 12;
int verdePin = 13;
int verdePed = 10;
int vermelhoPed = 9;
int estadoButton = 0;
void setup()
{
pinMode(vermelhoPin, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(amareloPin, OUTPUT);
pinMode(verdePin, OUTPUT);
pinMode(verdePed, OUTPUT);
pinMode(vermelhoPed, OUTPUT);
}
void loop()
{
estadoButton = digitalRead(buttonPin);
if(estadoButton == HIGH ){
digitalWrite(verdePin, HIGH);
digitalWrite(vermelhoPin, LOW);
digitalWrite(vermelhoPed, HIGH);
}
else{
delay(5000);
digitalWrite(verdePin, LOW);
digitalWrite(amareloPin,HIGH);
delay(5000);
digitalWrite(amareloPin, LOW);
digitalWrite(vermelhoPin, HIGH);
digitalWrite(vermelhoPed, LOW);
digitalWrite(verdePed, HIGH);
delay(5000);
digitalWrite(verdePed, LOW);
digitalWrite(vermelhoPed, HIGH);
delay(1000);
digitalWrite(vermelhoPed, LOW);
delay(1000);
digitalWrite(vermelhoPed, HIGH);
delay(1000);
digitalWrite(vermelhoPed, LOW);
delay(1000);
digitalWrite(vermelhoPin, LOW);
digitalWrite(verdePin, HIGH);
digitalWrite(vermelhoPed, HIGH);
digitalWrite(verdePed, LOW);
}
}