Olimex Support Forum

DUINO => ARDUINO => Topic started by: vitaly on November 07, 2019, 09:54:16 AM

Title: analogWrite not working on OLIMEXINO-328
Post by: vitaly on November 07, 2019, 09:54:16 AM
Hi,
I'm trying to run a glowing led code on the board using A0 pin as analog output but I'm getting just an on/off led behavior.
I've tried to search the manual regarding analog or pwm output but found no single word about it.
Can somebody clarify this?
Title: Re: analogWrite not working on OLIMEXINO-328
Post by: Gerrit on November 07, 2019, 07:48:08 PM
You can't do that on A0

PWM output is possible on digital I/O pins 3, 5, 6, 9, 10 and 11


If you really need A0 you can bit bang-it.

https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM (https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM)
Title: Re: analogWrite not working on OLIMEXINO-328
Post by: vitaly on November 10, 2019, 12:49:51 PM
Thank you for help, Gerrit!
The only place to find this info is datasheet of the MCU I guess? Or I missed something in the Olimexino manual? All what it says that A0-A5 is analog pins, that it. So I thought it's analog input/output but appears it's input only. Seems the manual needs some improvements.
Anyways, thank you again!
Title: Re: analogWrite not working on OLIMEXINO-328
Post by: JohnS on November 10, 2019, 06:07:17 PM
Regardless, you're not using it as analog.  You're using it as digital with an on-off repetition fast enough to fool the eye.

It would actually make little sense to use analog with a diode (LED)...

John