"The Arduino Due supports analogWrite() on pins 2 through 13, plus pins DAC0 and DAC1. Unlike the PWM pins, DAC0 and DAC1 are Digital to Analog converters, and act as true analog outputs. "
Let us know if that works, as I believ ethat it will!
Yes it works fine with PWM pins. I actually thought analogWrite can also work on Analog pin but i was wrong.
However the thing that was confusing me is.. when i analogWrite on an analog In pin (for example A0 or A1 etc). It used to dip voltage while printing on serial port. Why was this happening?
So basically, the voltage fluctuates with serial port's output.
However the thing that was confusing me is.. when i analogWrite on an analog In pin (for example A0 or A1 etc). It used to dip voltage while printing on serial port. Why was this happening?
Using analogWrite with any value from 0 to 127 on any of the analog pins creates a 3-4 µs LOW_HIGH_LOW pulse on the pin. It is only compatible with the DAC and PWM pins. Using digitalWrite on any of the analog pins does not create this problem.
So basically, the voltage fluctuates with serial port's output.
Writing to the serial port is a blocking function, it increases the gap between the 4µs pulse for each analogWrite, therefore lowering the avg. voltage you would read on the port.