Last active
July 25, 2019 16:50
-
-
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.
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
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