We will learn how to use multiple switches and output to single analogRead in an Arduino.
We will be using same resistance resistors for this project.
This attached Arduino code is only for 12 switches.
To do other number of switches, we will test the voltages across the switches using the analogRead function in an Arduino.
An Arduino analogRead a voltage from 0 Volt to 5 Volts with a scale from 0 to 1023.
When no switch is pressed, it reads 1023.
When switch 1 is pressed, it reads 0.
When switch 2 is pressed, it reads 512.
When switch 3 is pressed, it reads 682.
When switch 4 is pressed, it reads 767.
When switch 5 is pressed, it reads 819. And so forth.
We will give some buffer for the voltage in the scale. For example, for 512, we will give a range from 510 to 514.
Hope you enjoy this tutorial.
Comments
Please log in or sign up to comment.