Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: MichBFreeman on Jul 09, 2013, 08:19 pm

Title: LED sine wave via analog pin
Post by: MichBFreeman on Jul 09, 2013, 08:19 pm
I'm trying to generate a sine wave on an LED. I've found plenty of examples using PWM to generate a sine wave on a digital pin, but I need one generated via an analog pin. Any help would be greatly appreciated!
Title: Re: LED sine wave via analog pin
Post by: fungus on Jul 09, 2013, 08:34 pm

I'm trying to generate a sine wave on an LED. I've found plenty of examples using PWM to generate a sine wave on a digital pin, but I need one generated via an analog pin. Any help would be greatly appreciated!


Arduino has no analog outputs. The analog pins are input-only. PWM is the only way to do this.
Title: Re: LED sine wave via analog pin
Post by: MichBFreeman on Jul 09, 2013, 08:35 pm
Oh, well that's good to know. Sorry if that was a pretty basic question, I'm very new to all this. Thanks for the help, though!
Title: Re: LED sine wave via analog pin
Post by: CrossRoads on Jul 09, 2013, 08:36 pm
There is no analog output pin - the best you can do is fake it via a PWM pin.
Or, get an external DAC such MCP4821 or MCP4921
http://www.digikey.com/product-detail/en/MCP4921-E%2FP/MCP4921-E%2FP-ND/716280 external reference voltage
http://www.digikey.com/product-detail/en/MCP4821-E%2FP/MCP4821-E%2FP-ND/951462 internal reference voltage
Title: Re: LED sine wave via analog pin
Post by: P18F4550 on Jul 09, 2013, 09:05 pm
6 Led's, 60 degrees out of phase, showing only the top half of the sine wave, it would'nt be hard to show the negative side using bi colour leds

(http://i818.photobucket.com/albums/zz102/FunkyGibbon_2010/Arduino_proto/th_SUNP0084.jpg) (http://i818.photobucket.com/albums/zz102/FunkyGibbon_2010/Arduino_proto/SUNP0084.mp4)