Spaces:
Runtime error
Runtime error
Commit
·
1b24a58
1
Parent(s):
e73b538
Create Arduino.ino
Browse files- Arduino.ino +32 -0
Arduino.ino
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
void setup(){
|
| 2 |
+
pinMode(2,OUTPUT);
|
| 3 |
+
pinMode(3,OUTPUT);
|
| 4 |
+
pinMode(4,OUTPUT);
|
| 5 |
+
digitalWrite(2,HIGH);
|
| 6 |
+
digitalWrite(3,HIGH);
|
| 7 |
+
digitalWrite(4,HIGH);
|
| 8 |
+
Serial.begin(9600);
|
| 9 |
+
}
|
| 10 |
+
void loop(){
|
| 11 |
+
if (Serial.available()){
|
| 12 |
+
String value = Serial.readStringUntil('\n');
|
| 13 |
+
if (value == "rh"){
|
| 14 |
+
digitalWrite(2,LOW);
|
| 15 |
+
}
|
| 16 |
+
else if (value == "rl"){
|
| 17 |
+
digitalWrite(2,HIGH);
|
| 18 |
+
}
|
| 19 |
+
else if (value == "gh"){
|
| 20 |
+
digitalWrite(3,LOW);
|
| 21 |
+
}
|
| 22 |
+
else if (value == "gl"){
|
| 23 |
+
digitalWrite(3,HIGH);
|
| 24 |
+
}
|
| 25 |
+
else if (value == "bh"){
|
| 26 |
+
digitalWrite(4,LOW);
|
| 27 |
+
}
|
| 28 |
+
else if (value == "bl"){
|
| 29 |
+
digitalWrite(4,HIGH);
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}
|