I've read there https://www.raspberrypi.org/documentation/usage/gpio/ that we have 4 pins which can be used as analog, but other people say that we use only 2, so what's the correct answer?
-
1analog what? ... input or output?– jsotolaNov 23, 2019 at 8:22
-
Unlike Arduino, Rpi does not have any ADC (Analog to Digital) pins. You need to use external ADC chips/modules, eg MCP3008.– tlfong01Nov 23, 2019 at 8:40
-
1The simple answer is "zero" without additional hardware.– DougieNov 23, 2019 at 14:47
-
The simplest answer is "Zero".– tlfong01Nov 24, 2019 at 0:10
1 Answer
The Raspberry Pi has NO analogue GPIO. All the GPIO are digital only.
Perhaps you are being confused by some Arduino terminology. If a digital GPIO is used to generate PWM they often incorrectly refer to that GPIO as an analogue output.
If that's the case you are probably referring to the Pi's hardware PWM (output) capability. The Pi's with the 40 pin header (and the compute modules) can provide hardware PWM on GPIO 12, 13, 18, 19. However there are only two PWM channels so GPIO 12/18 will have identical outputs as will GPIO 13/19.
-
1Note that PWM output is strictly speaking not an analog output, it's just a quickly switching digital output that may for some applications look like an analog output (i.e. when controlling the brightness of an LED).– PMFNov 23, 2019 at 13:37