I have quite a beginner-level question.
I want to control LEDs through an 'analogWrite(...)' function to dim them.
I did this with the digital pins '3' and '11' through the PWM wave.
This worked as intended at first, but since I am also using the tone() library for another part of this project this ran into problems where the LEDs did not work in combination with the speaker output. (refer: tone() and analogWrite what are the limits)
So I opted on using analog pins for the 2 LEDs since I thought that using analog pins for analog outputs seems perfect.
This works not as intended however.
The analog pins can be used for analog input, or digital input and output (but not the PWM output produced by analogWrite(), as that function uses timer modules).
Analog pins dont provide analog voltage outputs on most "traditional" "arduinos".
and you cant use "analogWrite" because that uses the timers for pwm.
However you CAN write your own "analogOut" routine using millis (or micros) timing to generate low speed PWM signals, provided you dont mess with timer 0.
@Bennnn
from the Reference about tone():
"Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega)."
But the controller has more PWM pins than only 3 & 11, you can use analogWrite() on any combination of 5, 6, 9 &10 pins on Uno/Nano without interference with tone()