Just got an Arduino and I'm messing around having some problems with the lights.
I believe I am using a common anode led, so I have the three color pins going through a 270 ohm resistor to 10, 11, and 12 on the arduino. The last is hooked directly to VSS.
Much like this: http://www.instructables.com/id/RGB-LED-Tutorial-using-an-Arduino-RGBL/step2/Testing/
Now, it is working oppositely to what I would predict. When I write analogWrite( red, 0 )
, the led is lit red, and 255 turns it off completely.
Now, adjusting the value from 0-254 barely adjusts the brightness at all. 255 is completely off after it flashes for a second.
Can anyone explain what exactly is going on?
Your LED is common anode so it works just the opposite of common cathode. Try this:
int PWM_value = xxx;
analogWrite(red, 255 - PWM_value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With