Encoder
Encoder: outputs the binary number of whichever input is 1.
Function table (2-bit example)
| I3 | I2 | I1 | I0 | Y1 | Y0 |
|---|---|---|---|---|---|
| 1 | X | X | X | 1 | 1 |
| 0 | 1 | X | X | 1 | 0 |
| 0 | 0 | 1 | X | 0 | 1 |
| 0 | 0 | 0 | 1 | 0 | 0 |
X means either 0 or 1
Pins
Inputs I0, I1… on the left, binary output Y on the right (higher number = higher bit).
How to use it
Turn a key or sensor position into a number, e.g. 8 buttons → a 3-bit key code.
Usage example
The opposite of a decoder: whichever input is 1, the output is its number. With I2 = 1 the output Y1 Y0 = 10.
Common mistakes
It's a priority encoder: when several inputs are 1, the highest number wins. All-zero inputs also give 0, which looks the same as I0 = 1.