-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patharduinoFromProcessingFiveLEDs.ino
71 lines (56 loc) · 1.12 KB
/
arduinoFromProcessingFiveLEDs.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
/***************************************
* arduinoToProcessingFiveLEDs
*
* Send to and receive from Processing
* over the Serial port.
*
* author: Ammon Edwin Shepherd
* date: 12 May 2021
* license: MIT License
* https://github.com/ammonshepherd/arduino-tuts/blob/master/LICENSE
****************************************/
int RED = 9;
int YEL = 10;
int GRE = 11;
int BLU = 12;
int WHI = 13;
void setup() {
pinMode(RED, OUTPUT);
pinMode(YEL, OUTPUT);
pinMode(GRE, OUTPUT);
pinMode(BLU, OUTPUT);
pinMode(WHI, OUTPUT);
Serial.begin(9600);
}
void loop() {
char val = 'x';
if (Serial.available()) {
val = Serial.read();
}
if (val == 'r') {
digitalWrite(RED, HIGH);
} else {
digitalWrite(RED, LOW);
}
if (val == 'y') {
digitalWrite(YEL, HIGH);
} else {
digitalWrite(YEL, LOW);
}
if (val == 'g') {
digitalWrite(GRE, HIGH);
} else {
digitalWrite(GRE, LOW);
}
if (val == 'b') {
digitalWrite(BLU, HIGH);
} else {
digitalWrite(BLU, LOW);
}
if (val == 'w') {
digitalWrite(WHI, HIGH);
} else {
digitalWrite(WHI, LOW);
}
delay(1000);
}