-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesafio.ino
75 lines (64 loc) · 1.04 KB
/
desafio.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
70
71
72
73
74
char dado;
byte pinos[] = {6, 7, 8, 9, 10, 11, 12, 13};
void setup()
{
Serial.begin(9600);
for (int x=0; x<=7; x++)
{
pinMode(pinos[x], OUTPUT);
}
}
void loop()
{
if (Serial.available() == 8)
{
for(char i=0; i<=7; i++)
{
dado = Serial.read();
switch(dado)
{
case '1':
digitalWrite(pinos[i], HIGH);
break;
case '0':
digitalWrite(pinos[i],LOW);
break;
case '2':
apaga_tudo();
first_sequencial();
break;
case '3':
apaga_tudo();
second_sequencial();
break;
case '4':
apaga_tudo();
break;
}
}
}
}
void first_sequencial()
{
for(int y=0; y<=7; y++)
{
digitalWrite(pinos[y], HIGH);
delay(500);
digitalWrite(pinos[y], LOW);
}
}
void second_sequencial()
{
for(int y=0; y<=7; y++)
{
digitalWrite(pinos[y], HIGH);
delay(700);
}
}
void apaga_tudo()
{
for(int y=0; y<=7; y++)
{
digitalWrite(pinos[y], LOW);
}
}