Last active
August 29, 2015 14:22
-
-
Save buildcircuit/686586bc1a995a4354b7 to your computer and use it in GitHub Desktop.
Relay ON/OFF with Smart phone app
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
void setup() { | |
// Open serial communications: | |
Serial.begin(9600); | |
pinMode(2, OUTPUT); | |
// send an intro: | |
Serial.println("Enter a value"); | |
Serial.println(); | |
} | |
void loop() { | |
// get any incoming bytes: | |
if (Serial.available() > 0) { | |
int thisChar = Serial.read(); | |
// say what was sent: | |
Serial.print("You sent me: \'"); | |
Serial.write(thisChar); | |
if (thisChar=='h') | |
{ | |
digitalWrite(2, HIGH); | |
} | |
else { | |
digitalWrite(2, LOW); | |
} | |
Serial.print("\' ASCII Value: "); | |
Serial.println(thisChar); | |
Serial.println(); | |
Serial.println("Give me another byte:"); | |
Serial.println(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment