Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@suadanwar
Last active July 25, 2019 16:50
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 suadanwar/6aebb1144971362330da5b802f041b91 to your computer and use it in GitHub Desktop.
Save suadanwar/6aebb1144971362330da5b802f041b91 to your computer and use it in GitHub Desktop.
This sample code is for Simple GUI to Control LED on Arduino with Processing's tutorial. This is Arduino sample code.
boolean state = false;
void setup() {
pinMode(3, OUTPUT); //Set pin as an output
Serial.begin(9600); //Start serial communication @9600 bps
}
void loop() {
if (Serial.available()) {
char val = Serial.read();
if (val == 't') {
if (state == false) {
state = true;
digitalWrite(3, HIGH);
} else {
state = false;
digitalWrite(3, LOW );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment