I have a simple question that I couldn’t solve (even after searching thoroughly this forum): how can I work with PWM on an analog pin like A0?
I’m trying with the usual command analogWrite() passing the pin number and a value between 0-255 as parameters, but the led connected to it blinks instead of fading. Anyone know why? Before you ask I tried also with values from 0-1023. Here’s the code:
for(int i=0; i<255; i++) {
analogWrite(rLed, i);
delay(delayTime);
Serial << "The current brightness value is: " << i << "\n";
}
for(int i=255; i>0; i--) {
analogWrite(rLed, i);
delay(delayTime);
Serial << "The current brightness value is: " << i << "\n";
}
"On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 through 13. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11."
If you use analogWrite() on a non-PWM pin you get HIG for values of 128 or more and LOW for values below 128.
That is exactly the result I get.. I guess I will need to write a custom PWM function to make it work.
I'm building a prototype with the Seeedstudio Filmduino and I have only those ports at my disposal.