![]() println( "Your RGBLED instancse is a " + ledType + " LED ") commonType= 0) ? "COMMON_CATHODE " : "COMMON_ANODE " println( "Welcome to the RGBLED Sample Sketch ") Report the LED type and pins in use to the serial port. How long to show each color in the example code (in milliseconds) int delayMs = 1000 # include // Declare an RGBLED instanced named rgbLed // Red, Green and Blue LED legs are connected to PWM pins 11,9 & 6 respectively // In this example, we have a COMMON_ANODE LED, use COMMON_CATHODE otherwise * RGBLedExample Example for the RGBLED Library Created by Bret Stateham, NovemYou can get the latest version from */ The following sketch should be loaded into the editor: From the Arduino IDE menu, select "File" | "Examples" | "RGBLED" | "RGBLedExample" You can open the example sketch from the Arduino IDE (assuming you following the installation instructions above). PWN values 0-255 cause a relative brightness on that pin color from all the way off (0) to all the way on (255). This seems to make more sense than the inverted value-to-brightness relationship on the Common Anode LEDs. PWM signals 0-255 on each pin vary that color from all the way off (0) to all the way on (255). You would then connect the R,G & B legs each to their own PWM capable digital PIN on the Arudino (with appropriate current limiting resistors of course). You connect the Cathode to ground (GND) on the Arduino. PWM values between 0 and 255 will show the color at a brightness relative to the PWM value.Ĭommon Anode RGB LEDs have a single, "common", Cathode. When the PWM value on a pin is 0, there is a 5V voltage drop relative to the common Anode, and the color is shown at full brightness. A PWM value of 255 basically means the pin is at 5V, and there is no voltage differential (no color) between the pin and the Anode. This is because the LED has a common anode connected to 5V. a PWM value of 0 turns that color all the way on, and a value of 255 turns that color all the way off. PWM signals 0-255 on each pin vary that color from all the way on (0) to all the way off (255). You connect the Anode to the Voltage supply (5Vdc in the case of the arduino). Now, open the Arduino IDE, and from the menu select "Sketch" | "Import Library.", and select the "RGBLED" library from the menu:Īnd the appropriate include statement should be added to the top of your sketch:Ĭommon Anode RGB LEDs have a single, "common", Anode. Navigate to the newly extracted folder, then right-click on it and select "Rename" from the pop-up menu: In the "Extract Compressed (Zipped) Folders" window, use the "Browse." button to locate your "/Documents/Arduino/Libraries" folder (as documented here), and click "Extract": ![]() Right click on the downloaded "RGBLED-master.zip" file, and choose **"Extract All." from the pop-up menu: As mentioned above, you can learn more about Library paths and installation methods here: For that reason, we will manually extract the folder to the appropriate folder so we can rename it. That makes the extracted folder name ( "RGBLED-master") not match the actual library name ( "RGBLED"). ![]() zip file and internal folder include "-master" as part of the name ( "RGBLED-master.zip") in our case. However, when you download a repository from GitHub, the. Note: Starting with v1.0.5 of the Arduino IDE, the ability to add new libraries is built in. ![]() You can read more about Library paths for each operating system here: This folder should have been created automatically for you when you installed the Arduino IDE. Next, we'll extract the zip file to the default arduino libraries folder on your computer. To install the "RGBLED" library on your computer:ĭownload the lasted zip file from this repository: It supports both Common Anode and Common Cathode RGB LEDs and has basic functions for showing specific RGB values, random values, and for displaying a "Hue, Saturation, Value" (HSV) color wheel. RGBLED is an Arduino library for controlling four pin RGB LEDs.
0 Comments
Leave a Reply. |