Skip to content

Instantly share code, notes, and snippets.

@fulminator
Created March 4, 2013 17:57
Show Gist options
  • Save fulminator/5084117 to your computer and use it in GitHub Desktop.
Save fulminator/5084117 to your computer and use it in GitHub Desktop.
const int ledPin = 13; // the pin that the LED is attached to
char incomingString[10];
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
int i = 0;
while (Serial.available() > 0) {
incomingString[i++] = (char)Serial.read();
delay(10);
}
// turn on the LED:
if (incomingString == "Ican2") {
digitalWrite(ledPin, HIGH);
}
// turn off the LED:
if (incomingString == "Ican22") {
digitalWrite(ledPin, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment