Reading 4 switches on one analog pin

Sorry, I googled this but the results are vague, at least for me. I remember a long time ago, one would wire the switches, map to read a value between 0 and 1023, and determine which was pressed. Only one would be at ant time. At least a link to some tutorial. Thanks.

Thousands of hits on Google.


Create a resistor ladder as shown above so each switch is switching in a different value resistor and you will get a different analogue read for each switch.

I already had this and other examples. Just wanted to understand why mapping to read between 0 and 1023. Ill check some more, Thanks.

On the Arduino UNO, analog inputs can be from 0 to 5 volts. These corresponded to the analog to digital converter giving a number from 0 to 1023.