hy,
i am a member of one senior learning program of arduino and have one problem to be solved,
i have to program arduiino by switches
i have solve it but not succesfuly
i have 5 rows of 4 switches swiches represent 4bits
arduino needs to read row by row
then when aarduino reads one row by the combination of swtches he neds turn one of the 10 leds
i have solve this problem with arduino mega by using 4 digital pins for every combination of switches
and my question is can i do somehow sequental read with only one set of 4 pins for all the switches
so the arduino first reads one row with 4 digital pins asignet to them
and then reads second row with same digital pins so that i can solve this problem with arduino uno?
Look at how the Keypad library solves the problem. It can read any number of rows and columns, as long as the hardware is wired to match its expectations.
charlieplexing
5 rows, use 5 pins out, one to each row of switches.
4 columns of switches. tie the first switch in each row together on the unused pin and then bring that to a pin on the arudino.
when row 2 is powered and switch 3 completes the circuit, then the pin that represents ALL pin-3 in all rows will show a switch is closed. since only row 2 has power you know row two, switch 3.
need to add a resistor between each column of switches before it gets to the pin. then, no matter how many pins in that column are energized, the current is limited.
thank you for fast ansvers,
arduino needs to read one row of switches and then do something like light up green led if it is combination for green led
and then needs to read second row of switches and do something like if it is combination for red led light it up....
so i need 5*4 digital pins for read
and 10 pins foroutput
but my question is can i read one row of switches with for pins an the arduino liht up led and ater that read second row of switches but with same 4 input pins so that i dont need 20 digital pis for reading
but my question is can i read one row of switches with for pins an the arduino liht up led and ater that read second row of switches but with same 4 input pins
You could use a resistor ladder, so that the voltage at an analog pin was different for each of the 5 switches, using just 4 analog pins.
if you put power OUT from pin 2 to the first row.
then any switch in that row, and only that row will complete the circuit.
then you scan pins 7 thru 10
then turn off power to pin 2, turn on power to pin 3, scan 7-10
Thank you Dave in nj this is very helpfull
and solving now is no problem
thanks to everyone
There is a whole section of the learning zone show how to expand both input and output by my count you only need six I/O pins 3 in and 3 out.
Mark