
Once the color sequence is complete, the program will loop back to the beginning and repeat the sequence. For each of these colors, we'll turn the necessary RGB LEDs on or off.Īfter uploading your code, the RGB LED will step through a color sequence beginning with all LEDs off ('black'), red, yellow, green, cyan, blue, magenta, and white. Keep this in mind as you prototype with the LED and mix your colors. turn on the LEDs you will set them LOW instead of HIGH. Note: for this particular LED, the wiring shares a common anode (+), which means to This code will step through the six primary and secondary colors, plus white and black. Serial.println("Basic Color Mixing w/ a Common Cathode RGB LED")
#ARDUINO RGB LED CHASING LED BITREAD EXAMPLE SERIAL#
while (!Serial) // Comment out to wait for serial port to connect to Serial Monitor. Serial.begin(9600) //initialize Serial Monitor Create integer variables for our LED pins: #define DEBUG 1 //1 = LEDs w/ serial output debug mode, comment one of these lines out using a syntax for a single line comment: //

in various combinations to create eight primary and secondary colors. This example uses digitalWrite() to turn the three LEDs on and off This example uses a tri-color, also known as an RGB This code is released under the MIT License ()


Written by: Gella and Ho Yun "Bobby" ChanĬreate primary and secondary colors on the tri-color (Red/Green/Blue) LilyPad Tri-Color LED: Basic Color Mixing Select LilyPad USB Plus if following along with the LilyPad ProtoSnap Plus.Ĭopy and paste the following code into the Arduino IDE and upload it to your LilyPad Arduino. The LilyPad Arduino Simple, LilyPad Arduino, and LilyPad Development Board, and Development Board Simple all use a LilyPad ATmega 328. Choose LilyPad Arduino USB if using a LilyPad Arduino USB. Upload the following code to your LilyPad Arduino, making sure to select the correct LilyPad board from the drop down menu below.
