According to my current (poor) understanding, only the PWM pins (with the ~) among the digital pins (ignoring Analog pins) can be passed to analogWrite()
. I understand the servo therefore - since interfaced by a variable voltage signal - must be connected to such a PWM pin.
- Why is the humble Piezo Buzzer not bound to this condition?
- Why can I connect the buzzer to a digital pin that is not PWM (and so should only be able to output binary LOW, HIGH voltage at some consistent frequency) and still achieve a varying sound by calls to the
tone()
function? - Surely under the limitations of being digital and non-PWM, the pin could only cause some consistent buzzer frequency?
I'm reading online that the Piezeo Buzzer does indeed require a PWM digital pin, but I can connect it to any digital pin on my Galileo gen2 and have it function seemingly correctly (differing tones produced).
Also, since slightly relevant; what exactly is the difference between a PWM digital pin and an analog pin, in terms of output? They both use PWM, right? Why can't even a PWM digital pin read analog input?
analogWrite
arduino uses.