Created
May 24, 2013 15:09
-
-
Save kobeBigs/bb12ebcfd518720c2b25 to your computer and use it in GitHub Desktop.
Serial Interface & RGB LED a simple sketch to randomly change colors of RGB LED and write out Serial output.
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
/** | |
* a simple sketch to randomly change colors of RGB LED | |
* and write out Serial output. | |
*/ | |
int redPin = 11; | |
int bluePin = 10; | |
int greenPin = 9; | |
//setup | |
void setup(){ | |
Serial.begin(9600); | |
} | |
//loop | |
void loop(){ | |
int valRedPin = random(0, 256); | |
int valBluePin = random (0, 256); | |
int valGreenPin = random (0, 256); | |
//write to RGB LED | |
analogWrite(redPin, valRedPin); | |
analogWrite(greenPin, valGreenPin); | |
analogWrite(bluePin, valBluePin); | |
//send Serial output to PC | |
Serial.print(analogRead(redPin)); | |
Serial.print(","); | |
Serial.print(analogRead(greenPin)); | |
Serial.print(","); | |
Serial.println(analogRead(bluePin)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment