-
Notifications
You must be signed in to change notification settings - Fork 0
/
ignore.ino
41 lines (35 loc) · 999 Bytes
/
ignore.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
String readString;
#define ledPin 13
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
digitalWrite(6,HIGH);
Serial.begin(9600);
Serial.println("serial-delimit-21"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(10); //small delay to allow input buffer to fill
char c = Serial.read(); //gets one byte from serial buffer
if (c == ',') {
break;
} //breaks out of capture loop to print readstring
readString += c;
} //makes the string readString
if (readString.length() >0) {
Serial.println(readString); //prints string to serial port out
if(readString=="w"){
digitalWrite(ledPin,HIGH);
}
if(readString=="s"){
digitalWrite(ledPin,LOW);
}
if(readString=="switch on"){
digitalWrite(ledPin,HIGH);
}
if(readString=="switch off"){
digitalWrite(ledPin,LOW);
}
readString=""; //clears variable for new input
}
}