Last active
December 13, 2015 19:38
-
-
Save benmanns/4964277 to your computer and use it in GitHub Desktop.
Controlling the LED by sending Y or N over the serial connection.
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() { | |
Serial.begin(9600); | |
pinMode(13, OUTPUT); | |
digitalWrite(13, LOW); | |
Serial.println("Y for on, N for off."); | |
} | |
int ledOn = 0; | |
void loop() { | |
int instruction = 0; | |
while (Serial.available() > 0) { | |
instruction = Serial.read(); | |
if (instruction == 89 && ledOn == 0) { | |
ledOn = 1; | |
digitalWrite(13, HIGH); | |
} | |
else if (instruction == 78 && ledOn == 1) { | |
ledOn = 0; | |
digitalWrite(13, LOW); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment