-
-
Save surinoel/20d61220dc1eec3d8cff153fcc3b92f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pinLED = 13; | |
int ledStatus = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
pinMode(pinLED, OUTPUT); | |
Serial.println("usage : write (turn on | turn off)"); | |
} | |
String Serialread() | |
{ | |
String buf =""; | |
char c; | |
while(Serial.available() > 0) { | |
c = Serial.read(); | |
buf.concat(c); | |
delay(10); | |
} | |
return buf; | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
String str = ""; | |
digitalWrite(pinLED, ledStatus); | |
str = Serialread(); | |
if(str == "") { | |
} | |
else if(str == "turn off") { | |
Serial.println(str); | |
ledStatus = 0; | |
} | |
else if(str == "turn on") { | |
Serial.println(str); | |
ledStatus = 1; | |
} | |
else { | |
Serial.println("usage : write (turn on | turn off)"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment