Unlike digitalWrite, which can be only HIGH (on) or LOW (off), In this code we'll step through twelve rainbow colors (primary, secondary, tertiary). Here we'll create a rainbow of tertiary colors by adding a 50%-brightness option. In this example we'll use analogWrite to control the brightness of the three channels LilyPad Tri-Color LED: Custom Color MixingĮxpand your color options using analogWrite and the LilyPad Tri-Color LED This example will cover a set of twelve tertiary colors.Ĭopy and paste the following code into the Arduino IDE and upload to your LilyPad Arduino. There are actually millions of color combinations available using RGB LEDs once you begin experimenting by adjusting the brightness/saturation of each channel. In this activity, you'll create tertiary colors by combining the three color channels at 50% brightness levels. In the last example, you created basic primary and secondary colors by turning the red, green, and blue channels on or off with different combinations. You will need to confirm that the sew tabs you connect to the tri-color LED have PWM capabilities - this code will run on a LilyPad Arduino USB, LilyPad Arduino Simple, LilyPad Arduino SimpleSnap, and LilyPad Main board without any changes needed. Adjusting the brightness of the red, green, and blue LEDs within the LED will allow you to create a new range of values and color combinations. In this example, you will but use analogWrite() function to change the brightness of each channel in relation to each other. Take a look a the graphic below to see what colors combine to create primary and secondary colors with light. Turning on all three colors will create white - this is called additive color. Combining the primary colors of light (red, green, and blue) gives different results than combining pigments in paints or inks. Turning on different combinations of three LEDs inside the RGB LED will create new colors. 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. Create integer variables for our LED pins: 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 () LilyPad Tri-Color LED: Basic Color MixingĬreate primary and secondary colors on the tri-color (Red/Green/Blue) 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |