![]() So sending 255 via analogWrite() turns the LED off, while a value of 0 turns it on at full brightness. Instead of turning a pin HIGH to illuminate the LED, you need to turn the pin LOW, to create a voltage difference across the diode. ![]() RGB LEDs with a common anode share a common power pin. With your remaining wires, connect your red cathode to pin 3, green cathode to pin 5, and blue cathode to pin 6 in series with the resistors. The wire from 5V should therefore connect that second pin from top, as in the connection scheme above. Check the datasheet for your specific LED to verify the pins, but they should be R, V+, G and B. Place the RGB LED on your breadboard with the longest pin as the second from the top. You should turn the LED so that the longest pin is the second from the left. A wire connects the 5V from the POWER connector of the board to the longest pin of the RGB LED. You'll need four wires to make the circuit above. You'll use the Arduino Software (IDE) serial monitor to send strings like "5,220,70" to the board to change the light color. The values are parsed into integers and used to determine the color of a RGB LED. Often people use a comma to indicate different pieces of information (this format is commonly referred to as comma-separated-values or CSV), but other characters like a space or a period will work too. ![]() This sketch uses the Serial.parseInt() function to locate values separated by a non-alphanumeric character.
0 Comments
Leave a Reply. |