-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.ino
63 lines (60 loc) · 1.77 KB
/
control.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
const int LED_PIN_1 = 2; // Substitua pelos pinos corretos para seus LEDs
const int LED_PIN_2 = 3;
const int LED_PIN_3 = 4;
const int LED_PIN_4 = 5;
const int LED_PIN_5 = 6;
void setup() {
Serial.begin(9600);
pinMode(LED_PIN_1, OUTPUT);
pinMode(LED_PIN_2, OUTPUT);
pinMode(LED_PIN_3, OUTPUT);
pinMode(LED_PIN_4, OUTPUT);
pinMode(LED_PIN_5, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
int num_fingers = Serial.parseInt(); // Lê o número de dedos da porta serial
if (num_fingers == 1) {
digitalWrite(LED_PIN_1, HIGH);
digitalWrite(LED_PIN_2, LOW);
digitalWrite(LED_PIN_3, LOW);
digitalWrite(LED_PIN_4, LOW);
digitalWrite(LED_PIN_5, LOW);
}
else if (num_fingers == 2) {
digitalWrite(LED_PIN_1, HIGH);
digitalWrite(LED_PIN_2, HIGH);
digitalWrite(LED_PIN_3, LOW);
digitalWrite(LED_PIN_4, LOW);
digitalWrite(LED_PIN_5, LOW);
}
else if (num_fingers == 3) {
digitalWrite(LED_PIN_1, HIGH);
digitalWrite(LED_PIN_2, HIGH);
digitalWrite(LED_PIN_3, HIGH);
digitalWrite(LED_PIN_4, LOW);
digitalWrite(LED_PIN_5, LOW);
}
else if (num_fingers == 4) {
digitalWrite(LED_PIN_1, HIGH);
digitalWrite(LED_PIN_2, HIGH);
digitalWrite(LED_PIN_3, HIGH);
digitalWrite(LED_PIN_4, HIGH);
digitalWrite(LED_PIN_5, LOW);
}
else if (num_fingers == 5) {
digitalWrite(LED_PIN_1, HIGH);
digitalWrite(LED_PIN_2, HIGH);
digitalWrite(LED_PIN_3, HIGH);
digitalWrite(LED_PIN_4, HIGH);
digitalWrite(LED_PIN_5, HIGH);
}
else{
digitalWrite(LED_PIN_1, LOW);
digitalWrite(LED_PIN_2, LOW);
digitalWrite(LED_PIN_3, LOW);
digitalWrite(LED_PIN_4, LOW);
digitalWrite(LED_PIN_5, LOW);
}
}
}