-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFinger_count_Arduino.ino
More file actions
36 lines (31 loc) · 994 Bytes
/
Finger_count_Arduino.ino
File metadata and controls
36 lines (31 loc) · 994 Bytes
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
#define LEND1 2 // Thumb
#define LEND2 3 // Index
#define LEND3 4 // Middle
#define LEND4 5 // Ring
#define LEND5 6 // Little
void setup() {
pinMode(LEND1, OUTPUT);
pinMode(LEND2, OUTPUT);
pinMode(LEND3, OUTPUT);
pinMode(LEND4, OUTPUT);
pinMode(LEND5, OUTPUT);
Serial.begin(9600);
Serial.println("Ready");
}
void loop() {
if (Serial.available() > 0) {
String command = Serial.readStringUntil('\n'); // Read the incoming string
Serial.print("Command received: ");
Serial.println(command);
// Ensure the command length is 5 (for 5 LEDs)
if (command.length() == 5) {
// Parse and set LED states based on the command string
digitalWrite(LEND1, command[0] == '1' ? HIGH : LOW);
digitalWrite(LEND2, command[1] == '1' ? HIGH : LOW);
digitalWrite(LEND3, command[2] == '1' ? HIGH : LOW);
digitalWrite(LEND4, command[3] == '1' ? HIGH : LOW);
digitalWrite(LEND5, command[4] == '1' ? HIGH : LOW);
}
}
delay(100);
}