Analog vs digital comes down to one question: how many values can the signal take? An analog signal can sit anywhere in a range, like a dimmer that can be a little up or a lot up. A digital signal has a fixed set of values, and in a microcontroller that usually means two: HIGH and LOW, like a light switch. A turning knob gives an analog signal. A push button gives a digital one.
The difference matters every time you plug in a sensor. It decides which pin you use, which function reads it, what the reading looks like and what can go wrong. This guide puts the two side by side in a table and a graph, shows how an ESP32 reads each kind, and sorts every sensor in the MakerBuddy kit into its group. It ends with a worked example, a short Arduino sketch, a no-code rule and the common mistakes, each with its fix.
Analog vs digital at a glance
SparkFun's analog vs digital tutorial (opens in a new tab) defines an analog signal as continuous, with an infinite number of possible values in its range, and a digital signal as one drawn from a finite set. Most digital signals in electronics use just two values. Here is what that means on a real board.
| Analog signal | Digital signal | |
|---|---|---|
| Values it can take | Any value in a range | A fixed set, usually two (HIGH and LOW) |
| What its graph looks like | A smooth, continuous line | Square steps that jump between levels |
| Everyday example | A dimmer, a volume knob, a microphone | A light switch, a doorbell button |
| How an ESP32 reads it | analogRead(), a number from 0 to 4095 | digitalRead(), HIGH or LOW |
| Pins that can read it | Only pins wired to the converter (ADC) | Almost any input pin |
| What it tells you | How much | Yes or no (or a coded number) |
| Weak spot | Small electrical noise changes the reading | Tells you nothing between the two levels |
| MakerBuddy kit examples | Light sensor, knob, MQ-2 gas sensor, soil sensor | Push button, PIR motion sensor, DHT11 |
- Values it can take
- Analog signal
- Any value in a range
- Digital signal
- A fixed set, usually two (HIGH and LOW)
- What its graph looks like
- Analog signal
- A smooth, continuous line
- Digital signal
- Square steps that jump between levels
- Everyday example
- Analog signal
- A dimmer, a volume knob, a microphone
- Digital signal
- A light switch, a doorbell button
- How an ESP32 reads it
- Analog signal
analogRead(), a number from 0 to 4095- Digital signal
digitalRead(), HIGH or LOW
- Pins that can read it
- Analog signal
- Only pins wired to the converter (ADC)
- Digital signal
- Almost any input pin
- What it tells you
- Analog signal
- How much
- Digital signal
- Yes or no (or a coded number)
- Weak spot
- Analog signal
- Small electrical noise changes the reading
- Digital signal
- Tells you nothing between the two levels
- MakerBuddy kit examples
- Analog signal
- Light sensor, knob, MQ-2 gas sensor, soil sensor
- Digital signal
- Push button, PIR motion sensor, DHT11
The 0 to 4095 range comes from Espressif's Arduino-ESP32 ADC reference (opens in a new tab), which gives analogRead() a default resolution of 12 bits on every ESP32 chip. Twelve bits make 4,096 steps, numbered 0 to 4095.

What an analog signal is
An analog signal is a voltage that changes smoothly to match something in the world. Turn a knob a little and the voltage moves a little. There is no smallest step: the voltage can be 1.6 V, 1.61 V or 1.613 V. Brightness, temperature, sound and distance all change smoothly like this, and SparkFun's tutorial gives a microphone's output as a classic analog signal.
The price of all those values is noise. SparkFun describes analog circuits as susceptible to noise: small, unwanted changes in voltage. A tiny wobble on an analog wire becomes a wobble in your reading, because the board cannot tell a real change from a stray one. That is why the MakerBuddy firmware takes four readings of each analog sensor and averages them before it shows a number.
A board cannot store "any value", so it has to measure the voltage and turn it into a number. That job belongs to the analog-to-digital converter, or ADC. The ESP32 datasheet (opens in a new tab) lists two 12-bit ADCs that can measure 18 channels. Once the ADC has done its work, the analog voltage has become digital data: a whole number the program can compare, store and send over Wi-Fi.
What a digital signal is
A digital signal is a voltage that is only ever meant to sit at one of a few levels. In microcontrollers there are two. SparkFun's tutorial notes that a high level is often 5 V, 3.3 V or 1.8 V, and a low level is usually 0 V. The ESP32 runs at 3.3 V, so its HIGH is near 3.3 V and its LOW is near 0 V.
Real wires are never perfect, so a chip needs rules for what counts as HIGH and what counts as LOW. The ESP32 datasheet sets them in its DC characteristics table, at a 3.3 V supply:
| Input voltage on an ESP32 pin | What digitalRead() gives |
|---|---|
| At least 0.75 × 3.3 V = 2.475 V | HIGH, guaranteed |
| At most 0.25 × 3.3 V = 0.825 V | LOW, guaranteed |
| Between 0.825 V and 2.475 V | No promise: it can read either way |
- Input voltage on an ESP32 pin
- At least 0.75 × 3.3 V = 2.475 V
- What `digitalRead()` gives
- HIGH, guaranteed
- Input voltage on an ESP32 pin
- At most 0.25 × 3.3 V = 0.825 V
- What `digitalRead()` gives
- LOW, guaranteed
- Input voltage on an ESP32 pin
- Between 0.825 V and 2.475 V
- What `digitalRead()` gives
- No promise: it can read either way
Source for the thresholds: the ESP32 Series datasheet (opens in a new tab), Table 5-3, high-level and low-level input voltage.
This gap is the strength of digital signals. A HIGH of 3.1 V and a HIGH of 3.3 V both read as HIGH, so a little noise changes nothing.
Digital is not only on and off. A digital wire can also carry a message: a fast pattern of HIGHs and LOWs that spells out a number. That is how the DHT11 and the DS18B20 temperature probe talk to the board. Another trick is timing: the HC-SR04 distance sensor holds its Echo pin HIGH for a time that matches the distance, according to the HC-SR04 datasheet (opens in a new tab). The wire only ever sees two levels, yet the board gets a full number out of it.
How a microcontroller reads analog and digital inputs
The two kinds of signal go into the chip through different doors.
Reading an analog input
analogRead(pin) asks the ADC to measure the pin's voltage and return a number. On the ESP32 that number runs from 0 to 4095 by default. Three details from Espressif's documentation shape what you see:
- The range has soft ends. At the Arduino core's default setting of 11 dB, the Arduino-ESP32 ADC reference (opens in a new tab) gives a measurable input of 150 mV to 3100 mV on the classic ESP32. Below about 0.15 V the reading sits at 0. Above about 3.1 V it sits at 4095.
- The number is not millivolts. The same page offers
analogReadMilliVolts(), which returns a calibrated result in millivolts when you need a real voltage. - Only some pins can do it. The ESP32 has two converters, ADC1 and ADC2, and Espressif's GPIO reference (opens in a new tab) says ADC2 pins cannot be used while Wi-Fi is on. A Wi-Fi project should keep its analog sensors on ADC1 pins.
MakerBuddy's four analog sensors sit on GPIO 32, 33, 34 and 35. The datasheet's pin table lists all four as ADC1 channels, so they keep reading while the board is on your Wi-Fi. The deeper guide, ESP32 ADC explained, covers accuracy and calibration.
Reading a digital input
digitalRead(pin) just asks which side of the line the voltage is on. It returns HIGH or LOW, and it works on almost any GPIO pin. There is one trap. A digital input with nothing driving it is "floating": it picks up stray charge and reads HIGH or LOW at random. A pull-up resistor fixes this by gently tying the pin to 3.3 V, so it reads HIGH until something pulls it down. The ESP32 has pull-ups built in. The datasheet gives them a typical value of 45 kΩ, and pinMode(pin, INPUT_PULLUP) switches one on. The guide to pull-up vs pull-down resistors explains the choice in more depth.
Analog sensor vs digital sensor: every sensor in the kit sorted
An analog sensor gives out a voltage that rises and falls with what it senses. A digital sensor gives out HIGH or LOW, or a coded message on a digital pin. Many digital sensors are analog sensors with a converter built in. Adafruit's DHT guide (opens in a new tab) says the DHT sensors contain a chip that does analog-to-digital conversion and sends out a digital signal with the temperature and humidity.
Here is every sensor in the MakerBuddy IoT Kit V1.0, sorted. The light sensor, button and knob are built into the board. The other six plug into labelled sockets.
| Sensor | Signal | Pin | How the board reads it | Dashboard card shows |
|---|---|---|---|---|
| Light sensor (LDR), built in | Analog | GPIO 35 | Four ADC reads averaged, scaled to 0–100 | Light Level, 0 to 100 |
| Turning knob (potentiometer), built in | Analog | GPIO 34 | Four ADC reads averaged, scaled to 0–100 | Potentiometer, 0 to 100 |
| MQ-2 smoke and gas sensor | Analog | GPIO 33 | Four ADC reads averaged, scaled to 0–100 | Gas Level, 0 to 100 |
| Capacitive soil moisture sensor | Analog | GPIO 32 | Four ADC reads averaged; raw 0–4095 plus a calibrated 0–100 | Soil Moisture, 0 to 100 |
| Push button, built in | Digital, on/off | GPIO 5 | digitalRead() with the pull-up on; LOW means pressed | Pressed or Released |
| PIR motion sensor (HC-SR501) | Digital, on/off | GPIO 18 | digitalRead(); HIGH means motion | Motion or None |
| DHT11 temperature and humidity | Digital data | GPIO 25 | A coded message on one wire, through a library | Temperature (DHT) and Humidity |
| DS18B20 waterproof probe | Digital data (1-Wire) | GPIO 26 | A coded message on one wire, through a library | Temperature (DS18B20) |
| HC-SR04 distance sensor | Digital pulse | Trig 15, Echo 2 | Times how long Echo stays HIGH | Distance, in cm |
- Sensor
- Light sensor (LDR), built in
- Signal
- Analog
- Pin
- GPIO 35
- How the board reads it
- Four ADC reads averaged, scaled to 0–100
- Dashboard card shows
- Light Level, 0 to 100
- Sensor
- Turning knob (potentiometer), built in
- Signal
- Analog
- Pin
- GPIO 34
- How the board reads it
- Four ADC reads averaged, scaled to 0–100
- Dashboard card shows
- Potentiometer, 0 to 100
- Sensor
- MQ-2 smoke and gas sensor
- Signal
- Analog
- Pin
- GPIO 33
- How the board reads it
- Four ADC reads averaged, scaled to 0–100
- Dashboard card shows
- Gas Level, 0 to 100
- Sensor
- Capacitive soil moisture sensor
- Signal
- Analog
- Pin
- GPIO 32
- How the board reads it
- Four ADC reads averaged; raw 0–4095 plus a calibrated 0–100
- Dashboard card shows
- Soil Moisture, 0 to 100
- Sensor
- Push button, built in
- Signal
- Digital, on/off
- Pin
- GPIO 5
- How the board reads it
digitalRead()with the pull-up on; LOW means pressed- Dashboard card shows
- Pressed or Released
- Sensor
- PIR motion sensor (HC-SR501)
- Signal
- Digital, on/off
- Pin
- GPIO 18
- How the board reads it
digitalRead(); HIGH means motion- Dashboard card shows
- Motion or None
- Sensor
- DHT11 temperature and humidity
- Signal
- Digital data
- Pin
- GPIO 25
- How the board reads it
- A coded message on one wire, through a library
- Dashboard card shows
- Temperature (DHT) and Humidity
- Sensor
- DS18B20 waterproof probe
- Signal
- Digital data (1-Wire)
- Pin
- GPIO 26
- How the board reads it
- A coded message on one wire, through a library
- Dashboard card shows
- Temperature (DS18B20)
- Sensor
- HC-SR04 distance sensor
- Signal
- Digital pulse
- Pin
- Trig 15, Echo 2
- How the board reads it
- Times how long Echo stays HIGH
- Dashboard card shows
- Distance, in cm
Pins and read methods follow the MakerBuddy firmware and the pin list in the technical details. The HC-SR501 datasheet (opens in a new tab) gives the PIR's output as 3.3 V high and 0 V low, well clear of the ESP32's 2.475 V line. The DS18B20 datasheet (opens in a new tab) describes its 1-Wire bus as one data wire plus ground.

Three of these surprise people. The DHT11 measures something smooth, temperature, yet sends it as digital data. The HC-SR04 measures distance, also smooth, yet uses a digital pin and a stopwatch. And the knob, which feels like a control rather than a sensor, is the clearest analog signal on the board. So "analog or digital" describes the signal on the wire, not the thing being measured.
The visual guide to types of sensors covers each one in detail.
A quick test: is this sensor analog or digital?
- 1
Read the pin labels. Modules often mark an analog output AO or A0 and a digital one DO or OUT.
- 2
Watch the reading change. Move your hand, turn the knob or breathe near it. Many small steps mean analog. Two values mean digital on/off.
- 3
Check what the datasheet asks for. If it needs a library or talks about a protocol, it is a digital data sensor.
In a class, this makes a good 15-minute sorting task. Give each pair the list of nine sensors and three columns. They test each one on the dashboard, predict its column, then check. Lesson 6 and Lesson 9 give the background, and the Week 7 light sensing lesson is a good place to try the analog half.
Worked example: following one reading from voltage to number
The knob, an analog input
Say the knob's middle pin sits at 1.65 V, half of 3.3 V.
- 1
The ADC turns voltage into a number. In an ideal 12-bit converter, 1.65 V ÷ 3.3 V × 4095 ≈ 2048. A real ESP32 is close but not exact, which is why
analogReadMilliVolts()exists. - 2
The firmware averages four reads. If they come back 2046, 2049, 2050 and 2047, the average is 8192 ÷ 4 = 2048.
- 3
The firmware scales 0–4095 to 0–100 with Arduino's
map(): 2048 × 100 ÷ 4095 = 50.01. Whole-number maths drops the fraction, so the Potentiometer card shows 50. - 4
If you set the Potentiometer Mapping card to LED PWM, the board takes one fresh raw reading of the knob, without averaging, and scales it to 0–255 instead. For a raw 2048: 2048 × 255 ÷ 4095 = 127.5, shown as 127. The blue light glows at about half brightness.
The numbers in step 4 match the Week 9 analog inputs lesson, which works the same example. One honest quirk from that lesson: on the V1.0 board the knob runs from 5 V. Near the end of its turn the voltage goes past what the converter can measure, so the card can reach 100 before the knob stops. The supply causes it; the knob is fine. The guide to how a potentiometer works explains the voltage split inside the knob.
The button, a digital input
- 1
With the button up, the pull-up holds GPIO 5 near 3.3 V. That is above 2.475 V, so
digitalRead()returns HIGH. - 2
Press the button and it joins GPIO 5 to ground, 0 V. That is below 0.825 V, so
digitalRead()returns LOW. - 3
The firmware flips the answer, so LOW shows as Pressed on the Push Button card.
There is no averaging and no scaling. The Week 6 digital inputs lesson uses this button as its first input. Hold it for about 3 seconds when you test it, because the board checks it once a second. Never hold it for 10 seconds: that erases the saved Wi-Fi name and password.

Digital outputs that act analog: PWM
Outputs split the same way. A pin that drives the buzzer or the relay is plainly digital: HIGH turns it on, LOW turns it off. That is why the MakerBuddy buzzer plays one tone. It is either sounding or silent.
Dimming the blue light looks analog, but the pin is still digital. It uses pulse width modulation, or PWM. Arduino's Basics of PWM (opens in a new tab) calls it a technique for getting analog results with digital means: the pin switches on and off very fast, and the share of time it spends on sets the brightness. On the 0 to 255 scale, analogWrite(255) asks for a 100% duty cycle and analogWrite(127) for 50%. Your eye averages the flicker, so the light looks half as bright.
The board uses PWM for three outputs and plain on/off for two:
| Output | Pin | Signal | What it means |
|---|---|---|---|
| Blue light | GPIO 12 | PWM, 0–255 | Brightness |
| Colour light (RGB) | GPIO 13, 14, 27 | PWM, 0–255 per colour, written as 255 minus the value | Colour mix on a common-anode light |
| SG90 servo | GPIO 19 | PWM at 50 Hz, pulses of 500–2500 µs | Angle from 0 to 180° |
| Buzzer | GPIO 4 | Digital on/off | One tone, on or off |
| Relay | GPIO 23 | Digital on/off | Contacts closed or open, low-voltage loads only |
- Output
- Blue light
- Pin
- GPIO 12
- Signal
- PWM, 0–255
- What it means
- Brightness
- Output
- Colour light (RGB)
- Pin
- GPIO 13, 14, 27
- Signal
- PWM, 0–255 per colour, written as 255 minus the value
- What it means
- Colour mix on a common-anode light
- Output
- SG90 servo
- Pin
- GPIO 19
- Signal
- PWM at 50 Hz, pulses of 500–2500 µs
- What it means
- Angle from 0 to 180°
- Output
- Buzzer
- Pin
- GPIO 4
- Signal
- Digital on/off
- What it means
- One tone, on or off
- Output
- Relay
- Pin
- GPIO 23
- Signal
- Digital on/off
- What it means
- Contacts closed or open, low-voltage loads only
Pins and signals follow the MakerBuddy firmware. A true analog output does exist on the chip: the ESP32 datasheet lists two 8-bit digital-to-analog converters, or DACs, on GPIO 25 and 26. MakerBuddy uses those two pins as plain digital data pins for the DHT11 and the probe instead. The PWM guide goes further into duty cycle and frequency.
Try it in Arduino: read an analog and a digital input side by side
This sketch reads the knob, an analog input on GPIO 34, and the button, a digital input on GPIO 5. It prints both once a second, so you can watch one move in small steps while the other jumps. Use the "esp32 by Espressif Systems" boards package (version 3.x), the ESP32 Dev Module board and the Serial Monitor at 115200 baud.
// MakerBuddy board (ESP32 Dev Module): one analog input next to one digital input.
// Uploading this replaces the MakerBuddy firmware until you upload that again.
const int KNOB_PIN = 34; // turning knob: analog, an ADC1 pin, input-only
const int BUTTON_PIN = 5; // push button: digital, joins the pin to ground when pressed
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP); // hold the pin HIGH until the button pulls it LOW
}
void loop() {
// Analog: average four reads, the way the MakerBuddy firmware does
long sum = 0;
for (int i = 0; i < 4; i++) {
sum += analogRead(KNOB_PIN); // 0 to 4095
}
int raw = sum / 4;
int percent = map(raw, 0, 4095, 0, 100); // the dashboard's 0-100 scale
uint32_t mv = analogReadMilliVolts(KNOB_PIN); // calibrated millivolts
// Digital: only two answers
bool pressed = digitalRead(BUTTON_PIN) == LOW; // LOW means pressed
// Turn the analog value into a yes/no decision of your own
bool turnedUp = percent > 50;
Serial.print("Knob raw: "); Serial.print(raw);
Serial.print(" 0-100: "); Serial.print(percent);
Serial.print(" mV: "); Serial.print(mv);
Serial.print(" turned up: "); Serial.print(turnedUp ? "yes" : "no");
Serial.print(" Button: "); Serial.println(pressed ? "PRESSED" : "released");
delay(1000); // once a second, the same pace as the MakerBuddy firmware
}What to look for:
- 1
Turn the knob slowly. The raw number climbs through hundreds of values, and the 0–100 figure follows in small steps. That is an analog signal.
- 2
Press the button. It jumps straight from released to PRESSED with nothing in between. That is a digital signal.
- 3
Compare raw with mV. They rise together but are not the same number.
analogRead()gives steps of the converter;analogReadMilliVolts()gives a calibrated voltage, as the Arduino-ESP32 ADC reference (opens in a new tab) describes. - 4
Watch "turned up". The line
percent > 50turns an analog reading into a digital decision. Every threshold in every project does this.
When you finish, put the MakerBuddy firmware back with the steps in install by USB.
No code: turning an analog reading into a yes/no rule
You do not need a sketch to see analog become digital. A MakerBuddy rule does it for you. It compares one sensor with a number using greater than, less than, at least, at most or about equal, and the answer is always true or false. Here is a night light built from two rules in the dashboard:
- 1
Rule "Dark: light on". Mode: Condition. Sensor: Light Level, less than 25. Step 1: blue light on, wait 1 second.
- 2
Rule "Bright: light off". Mode: Condition. Sensor: Light Level, greater than 35. Step 1: blue light off, wait 1 second.
- 3
Save both rules and turn them on. They run on the board, not in your browser.
- 4
Cover the light sensor. Once the reading has stayed under 25 for 0.3 seconds, the first rule starts and the blue light comes on.
- 5
Uncover it. When the reading passes 35, the second rule turns the light off.
The gap between 25 and 35 is deliberate. With a single line at 30, a reading that wobbles between 29 and 31 would flick the light on and off. With a gap, the light holds its state until the room is clearly dark or clearly bright. Your numbers will differ from room to room, so measure first, as the Week 7 lesson does. The guide to picking sensor thresholds goes into choosing them.
Digital sensors need no threshold at all. The dashboards offer the button and the motion sensor only as true or false, as the Week 26 sensor-based control lesson shows. A rule can join two tests with AND or OR, so "motion is true AND Light Level less than 25" mixes one digital input with one analog input. The board reads each sensor once a second, and a board holds up to 10 rules of up to 10 steps each.
Common analog and digital mistakes, with causes and fixes
An analog reading goes wrong as soon as Wi-Fi connects
- Symptom: your own sketch reads a sensor well until the board joins Wi-Fi, then the numbers stop making sense.
- Cause: the sensor is on an ADC2 pin. Espressif's GPIO reference (opens in a new tab) says ADC2 pins cannot be used while Wi-Fi is on.
- Fix: move the sensor to an ADC1 pin. On MakerBuddy, GPIO 32 to 35 are ADC1.
A digital input flickers between HIGH and LOW with nothing touching it
- Symptom: the input reports presses or motion that never happened.
- Cause: the pin is floating, with no pull-up or pull-down, so its voltage drifts through the zone between 0.825 V and 2.475 V where the ESP32 datasheet makes no promise.
- Fix: use
pinMode(pin, INPUT_PULLUP)for a button that connects to ground, or add an external resistor.
digitalRead() on an analog sensor only ever says HIGH or LOW
- Symptom: you read the soil or light sensor with
digitalRead()and get a flip at some unknown level instead of a number. - Cause:
digitalRead()only reports which side of the threshold the voltage is on. All the "how much" is thrown away. - Fix: read analog sensors with
analogRead()on an ADC pin, then make your own threshold in code or in a rule.
analogRead() on a digital data sensor gives nonsense
- Symptom: you read the DHT11's data pin with
analogRead()and get random numbers. - Cause: the DHT11 sends a coded message of fast pulses. Adafruit's DHT guide (opens in a new tab) describes it as a digital signal on a single pin, read no more than once a second.
- Fix: use a DHT library, which decodes the pulses into temperature and humidity.
The analog reading never reaches 0 or never moves off 4095
- Symptom: the knob or sensor sits at 0 or 4095 over part of its travel.
- Cause: the voltage is outside the ADC's measurable range. At 11 dB that range is about 150 mV to 3100 mV, per the Arduino-ESP32 ADC reference (opens in a new tab).
- Fix: nothing is broken. Use the part of the range that moves, or use
analogReadMilliVolts()when you need the real voltage.
When analog is the better choice, and when digital is
Choose an analog sensor when you need to know how much. A soil sensor that says 18 out of 100 lets you water at 20 and stop at 60. Analog sensors are also simple: one voltage, one wire, one number.
Choose a digital on/off sensor when the question is yes or no. Is someone there? The PIR does its own processing and hands you a clean answer, so you do not have to guess a threshold.
Choose a digital data sensor when you need an accurate number over a long wire or in a noisy place. The DS18B20 sends its temperature as a coded number, so a little noise on the cable does not shift it. The cost is a library and a reading that takes time.
Analog is not out of date. Every digital sensor in this post starts with something smooth in the world. If you would rather learn on real parts than in a simulator, the MakerBuddy IoT Kit has all nine sensors from the sorting table: four analog, two digital on/off and three digital data or pulse.
For the bigger picture, the guide to the 12 ideas you need before your first circuit puts analog and digital signals next to voltage, current and PWM. More explainers are on the MakerBuddy blog.
FAQ
What is the main difference between analog and digital?
An analog signal can take any value in a range and changes smoothly. A digital signal has a fixed set of values, usually two, HIGH and LOW, and jumps between them. Analog tells you how much; digital tells you yes or no, or sends a coded number.
Is the real world analog or digital?
Most of what sensors measure changes smoothly, so it behaves like an analog signal: light, heat, sound and distance. Computers work with numbers, so a converter (an ADC) measures the smooth signal and turns it into digital data. A sensor such as the DHT11 does that conversion inside its own case.
Is analog still used today?
Yes. Microphones, light sensors, potentiometers and soil sensors all give analog signals, and a microcontroller's ADC is there to read them. What has changed is that the analog signal is usually turned into digital data close to where it is measured, then stored and sent as numbers.
What are examples of analog and digital devices?
Analog: a dimmer, a volume knob, a microphone, a light-dependent resistor and a capacitive soil sensor. Digital: a push button, a PIR motion sensor, a DHT11 temperature and humidity sensor and a computer. Many devices mix both, with analog parts at the edges and digital processing in the middle.
Is a cell phone analog or digital?
A modern phone is a digital device. Inside, it works with numbers. Its edges are analog, though: the microphone produces an analog signal, which converters turn into digital data, and the speaker turns numbers back into smooth sound.
Is a potentiometer analog or digital?
A potentiometer gives an analog signal. Turning it moves a contact along a resistive track, so its middle pin gives out a voltage anywhere between its two ends. On an ESP32 you read it with analogRead(), which returns 0 to 4095.
Is the DHT11 an analog or a digital sensor?
The DHT11 is a digital sensor. It measures temperature and humidity with analog parts, but a chip inside converts the readings and sends them as a digital signal on one data pin. You read it with a library, not with analogRead().
Is PWM analog or digital?
PWM is a digital signal used to get an analog-like result. The pin is only ever fully on or fully off, but it switches so fast that a light or motor responds to the average. On the 0 to 255 scale, 127 means on about half the time.
Sources
- SparkFun, Analog vs. Digital (opens in a new tab): analog signals are continuous with infinite values in a range; digital signals come from a finite set, usually two levels; analog circuits are susceptible to noise; microphone output is analog.
- Espressif, ESP32 Series datasheet v5.3 (opens in a new tab): two 12-bit SAR ADCs on 18 channels; two 8-bit DACs on GPIO 25 and 26; Table 5-3 input HIGH at 0.75 × VDD or more and LOW at 0.25 × VDD or less; internal pull-up typically 45 kΩ; GPIO 32 to 35 as ADC1 channels.
- Espressif, Arduino-ESP32 ADC API reference (opens in a new tab):
analogRead()defaults to 12 bits, 0 to 4095; 11 dB measurable range of 150 mV to 3100 mV on the ESP32;analogReadMilliVolts()returns calibrated millivolts. - Espressif, ESP-IDF GPIO and RTC GPIO reference for the ESP32 (opens in a new tab): ADC2 pins cannot be used when Wi-Fi is used.
- Arduino, Basics of PWM (Pulse Width Modulation) (opens in a new tab): PWM gets analog results with digital means;
analogWrite(255)is a 100% duty cycle andanalogWrite(127)50%. - Adafruit, DHT humidity and temperature sensors overview (opens in a new tab): an internal chip does analog-to-digital conversion and sends a digital signal on a single pin; no more than one reading a second.
- HC-SR501 PIR motion sensor datasheet (Electrokit copy) (opens in a new tab): output high 3.3 V, low 0 V.
- Elecfreaks, HC-SR04 ultrasonic ranging module datasheet (SparkFun copy) (opens in a new tab): the Echo pulse width is in proportion to the distance.
- Maxim Integrated, DS18B20 datasheet (SparkFun copy) (opens in a new tab): 1-Wire interface, one data wire plus ground.




