i hope i don't come off as a complete idiot but.. what's going on in this tutorial?
(i can't post a link in this post because it's my first i guess? check the next one)
i use a regular arduino. it works just fine, and i played with modifying the code for a bit to get comfortable with writing code for the arduino, and then i realized i'm missing something here.
in that circuit, where is the electricity going? the PWMs are supplying electricity (the output signal, right?), and so is +5V right? so where does it go? or am i just a little backwards and +5V is the end of the circuit?
feel free to point me in the direction of a page or three or some google terms if that's easier than explaining. i just don't know what to look for. :-/
I suppose that you followed the tutorial works that your rgb LED is working, right? And you only wonder WHY it does work?
PWM is not 5V. It is 5V for a short period of time and then 0V for another short period of time. The longer the 5V part is, the higher the resulting "analog" voltage seems to be. But as long as you don't put 100% on the PWM line, there will be some short periods where the line has 0V level... and this is the reason why the LED illuminates.
yes, it is not wrong if you put it that way. Of course this is a simple explanation... but not incorrect.
You can also think of the PWM output as an analog signal... For example let it be 2.5V (50% PWM load). You can connect the Anode of the LED to 5V and the Cathode to this 2.5V level...
You'll sometimes find that people say that the Arduino pins can both "source" and "sink" current. That means that they can supply current from the 5V power supply into a load that then connects to Ground and they can take in current that has passed through a load from the 5V power supply, and send it to Ground. When the pin is HIGH, it's sourcing current and its voltage is 5V; when a pin is LOW, it's sinking current and its voltage is 0V.
PWM pins switch from HIGH to LOW and back again all the time, quite quickly (too fast to cause flicker). They spend more or less time LOW compared to HIGH, which makes a LED get brighter or dimmer. That makes them equivalent to an analog output pin (which we don't have) provided you think about the average voltage.
ah, ok, i understand now. that's very helpful to know! i had no idea that the PWMs sank the current while low. thank you both for your help! [smiley=thumbsup.gif]