Skip to content

Instantly share code, notes, and snippets.

@buildcircuit
Created May 24, 2015 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buildcircuit/080ad0c2093b06b193ae to your computer and use it in GitHub Desktop.
Save buildcircuit/080ad0c2093b06b193ae to your computer and use it in GitHub Desktop.
Simple lamp on off
void setup() {
// Open serial communications:
Serial.begin(9600);
pinMode(9, 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(9, HIGH);
}
else {
digitalWrite(9, 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