Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arduino RGB LED issues

Tags:

arduino

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?

like image 337
grep Avatar asked Nov 05 '11 02:11

grep


1 Answers

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);
like image 126
ctasdemir Avatar answered Nov 24 '22 00:11

ctasdemir