Skip to content

Instantly share code, notes, and snippets.

@detik19
Created June 4, 2016 13:18
Show Gist options
  • Save detik19/b177544d8c197070251776a2e12a532f to your computer and use it in GitHub Desktop.
Save detik19/b177544d8c197070251776a2e12a532f to your computer and use it in GitHub Desktop.
Arduino Server Serial Wifi
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