I'm new here and also new to arduino. I'd like some help on my first project. =)
In my project I have to connect 6/7 switches to an arduino. I've done some research and I found that it was possible by:
connecting them individually to digital input pins
connect them together into a single analog pin and use resistors as "steps" to differentiate each pressed switch.
Unfortunately I can use options 1 and 2.
Also I found that it was possible to use digital inputs with matrices. I was thinking to do something simular to what computers keyboards (rollover). I found some examples like this one:
Then I thought something like binary tables, bytes and stuff (000,001,010..). And then I came up with this idea:
Where D1, D2, D3 are arduino digital inputs and SW1-7 switches.
The user will action the switches individually and never simultaneously.
Will this schema cause any problem, short-circuit? SW4,SW5,SW6 and SW7 are connected together.
I've read something about pullup,pulldown resistors. Do I have to use any here? I'm planing to only read the digital input values to a computer. No leds or any other load.
With your last arrangement flipping any 1 switch will always give you D1, D2, and D3. You have shorted all three lines together.
With a handfull of diodes you could make it work by replacing each junction with a diode. Turn on pull ups on D1, D2, and D3, connect the diodes cathode to the switch and anode to the desired Dn lines. other side of the switches to ground. Looks like about 12 diodes will be needed.
Due_unto:
With your last arrangement flipping any 1 switch will always give you D1, D2, and D3. You have shorted all three lines together.
With a handfull of diodes you could make it work by replacing each junction with a diode. Turn on pull ups on D1, D2, and D3, connect the diodes cathode to the switch and anode to the desired Dn lines. other side of the switches to ground. Looks like about 12 diodes will be needed.
You're right. I definitely didn't see that, I made a silly mistake :o :o :o haha
Good idea, thank you. Just to clarify another question.
Is there any problem to connect a digital I/O pin configured as input to another I/O pin also configured as input? Do I need to use any resistor in that situation?
Is there any problem to connect a digital I/O pin configured as input to another I/O pin also configured as input? Do I need to use any resistor in that situation?
No, you don't need a resistor. You can't connect outputs together, but you can connect inputs together.
But, why would you need to read the same thing on two different input-pins? (You might want to connect the inputs of two different microcontrollers, and that's OK too.)