Created
August 23, 2010 21:50
-
-
Save winhamwr/546417 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const int ledGreenPin = 3; | |
const int ledBluePin = 4; | |
int incomingByte; | |
void setup() { | |
// initialize serial communication: | |
Serial.begin(9600); | |
Serial.print("YOYOYO\n"); | |
// initialize the LED pin as an output: | |
pinMode(ledRedPin, OUTPUT); | |
pinMode(ledGreenPin, OUTPUT); | |
pinMode(ledBluePin, OUTPUT); | |
} | |
void redOn() { | |
digitalWrite(ledRedPin, HIGH); | |
digitalWrite(ledGreenPin, LOW); | |
digitalWrite(ledBluePin, LOW); | |
} | |
void greenOn() { | |
digitalWrite(ledRedPin, LOW); | |
digitalWrite(ledGreenPin, HIGH); | |
digitalWrite(ledBluePin, LOW); | |
} | |
void blueOn() { | |
digitalWrite(ledRedPin, LOW); | |
digitalWrite(ledGreenPin, LOW); | |
digitalWrite(ledBluePin, HIGH); | |
} | |
void testResponse() { | |
Serial.print("SUCCESS\n"); | |
} | |
void loop() { | |
// see if there's incoming serial data: | |
if (Serial.available() > 0) { | |
// read the oldest byte in the serial buffer: | |
incomingByte = Serial.read(); | |
if (incomingByte == 'R') { | |
redOn(); | |
} | |
if (incomingByte == 'G') { | |
greenOn(); | |
} | |
if (incomingByte == 'B') { | |
blueOn(); | |
} | |
if (incomingByte == 'T') { | |
digitalWrite(ledRedPin, HIGH); | |
digitalWrite(ledGreenPin, HIGH); | |
digitalWrite(ledBluePin, HIGH); | |
testResponse(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment