Electronics
Logic levels: what voltage is a 1, and what is a 0?
A logic level is a range of voltages that a digital input reads as one bit. On 5 V CMOS logic, like an Arduino Uno's chip, anything at or below 1.5 V reads as 0 (LOW), and anything at or above 3.0 V reads as 1 (HIGH). Between them is a gap that counts as neither: a gate might read it either way.
Why only two levels
A wire could carry any voltage, so why throw that away? Because two levels far apart are hard to confuse. An output drives a 0 at close to 0 V, so noise has to lift it by a full 1.5 V before it even reaches the gap. A 1 near 5 V has 2 V of room before it falls to 3.0 V.
That safety distance between a driven level and the nearest threshold is the noise margin. Squeeze ten levels into the same 5 V instead and they'd sit half a volt apart, so a quarter of a volt of noise could change a digit. Two levels let a signal pass through long wires, cheap parts and noisy rooms and still arrive exactly.
Live experiment
Send a number down a noisy wire
Set a number on four switches worth 8, 4, 2 and 1 and send it down a long wire as two levels, 5 V or 0 V. Turn up the noise and see what it takes to make a bit misread. Then send the same number as ten levels, half a volt apart.
“Binary and logic levels” is lesson 1 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 42 before it first.
Logic families disagree
Not every chip uses the same thresholds. The common ones:
| Family | Reads LOW at or below | Reads HIGH at or above |
|---|---|---|
| 5 V CMOS | 1.5 V | 3.0 V |
| 5 V TTL | 0.8 V | 2.0 V |
| 3.3 V LVCMOS | 0.8 V | 2.0 V |
Datasheets give these as VIL and VIH, the input thresholds, and VOL and VOH, how close the outputs get to the rails. A connection works when the driver's VOH is above the receiver's VIH and its VOL is below the receiver's VIL.
Mixing 3.3 V and 5 V
A 3.3 V sensor driving a 5 V Arduino input usually works: 3.3 V clears 3.0 V, if only by 0.3 V. The other direction is the dangerous one. A 5 V output into a 3.3 V chip can push current through its protection diodes and damage it, unless the pin is marked 5 V tolerant. A divider, like 1 kΩ over 2 kΩ, or a level-shifter chip fixes it.
From levels to numbers
One wire is one bit. Line up several and each one is a place value, 1, 2, 4, 8, so four wires carry any number from 0 to 15. The levels are what make each of those bits trustworthy.
Free lesson
Now build it yourself
Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.
“Binary and logic levels” is lesson 1 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 42 before it first.
Or start from the very first lesson, no account neededWork it out
Practice questions
Three quick questions from the lessons. Pick an answer to check it.
Show the answer
Answer: twice the wire to its right. The places double from right to left, like cards worth 1, 2, 4 and 8 dots. That's why one row of wires can say any number in its range, in exactly one way.
- Why not “the same as every other wire”? If every wire counted the same, 1010 and 0101 would mean the same number. The places double, so every pattern means a different number.
- Why not “one more than the wire to its right”? Adding one per place gives 1, 2, 3, 4, which can't make each number in exactly one way. Binary places double: 1, 2, 4, 8.
Show the answer
Answer: unpredictably. A floating input is pushed around by stray charge, so it reads HIGH or LOW at random. A pull-up gives it a definite level.
- Why not “always LOW”? Nothing holds a floating pin at 0 V. Stray charge and nearby signals push it about, so it reads either level.
- Why not “always HIGH”? Nothing holds it at 5 V either, unless a pull-up is switched on. Floating, it drifts and reads HIGH or LOW at random.
Show the answer
Answer: 1 or 0, nothing in between. That's the whole deal with digital. A wire is either on (1) or off (0). Anything more complicated is built from lots of those.
- Why not “Any voltage from 0 to 5”? A real wire can sit at any voltage, but a logic circuit reads it as one of just two values, 1 or 0.
- Why not “A number from 0 to 15”? One wire carries one bit. Counting to 15 takes four wires, worth 8, 4, 2 and 1.
- Why not “Only 1”? A wire that could only be 1 would carry no information. It's useful because it can be either.
“Binary and logic levels” is lesson 1 of 6 in Logic Grid, Electronics World 7. Free with an account. Lessons unlock in order, so you’ll do the 42 before it first.
Questions people ask
What voltage is HIGH on an Arduino?
On a 5 V Arduino Uno, an input reads HIGH at about 3.0 V or more and LOW at about 1.5 V or less: 60% and 30% of the supply. Its outputs drive close to 5 V and 0 V, well clear of both thresholds.
Can I connect a 3.3 V output to a 5 V input?
Often, yes: 3.3 V clears a 5 V CMOS input's 3.0 V threshold, though with only 0.3 V to spare. The other way is riskier: 5 V into a 3.3 V input can damage it unless the pin is 5 V tolerant, so use a divider or a level shifter.
What happens to a voltage between the two levels?
It's undefined: a gate might read it as either bit, and the reading can change from moment to moment. Inputs left floating, or slow signals passing through the gap, cause exactly that. Pull-ups and Schmitt-trigger inputs prevent it.
Related topics
- Binary numbers explainedPlaces worth 1, 2, 4 and 8: add up the bits that are on, and four wires count to 15.
- Comparator hysteresis and the Schmitt triggerTwo thresholds instead of one: how a feedback resistor stops a comparator chattering on a noisy signal.
- What is a pull-up resistor?Why an input pin needs a pull-up, and why a pressed button reads LOW.
- Logic gates explainedAND, OR, NOT, XOR and their bubbled twins: each one's rule is a truth table.