Created
June 4, 2016 13:18
-
-
Save detik19/b177544d8c197070251776a2e12a532f to your computer and use it in GitHub Desktop.
Arduino Server Serial Wifi
This file contains 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
String a; | |
const int ledPin = 13; // the number of the LED pin | |
int ledState = LOW; // ledState used to set the LED | |
void setup() { | |
Serial.begin(9600); | |
pinMode(ledPin, OUTPUT); | |
} | |
void loop() { | |
delay(1000); | |
///Serial.println("Halo ESP8266, Assalamualaikum :)"); | |
if (Serial.available()) { | |
/* read the most recent byte */ | |
a = Serial.readString(); | |
/*ECHO the value that was read, back to the serial port. */ | |
Serial.println(a); | |
if(a=="1"){ | |
ledState = HIGH; | |
}else if(a=="0"){ | |
ledState = LOW; | |
} | |
digitalWrite(ledPin, ledState); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment