Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement