Arduino question

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
ok people just very simply if I used an arduino mega and used every pin (54 in total from memory) how would it read all the sensors at once without drawing too many amps?
am trying to make a gamepad with a few buttons and axes and they will be getting pressed or toggled in unison some times so am trying to figure out how it works so I don't fry the boards.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
The inputs are a high impedance, so reading the inputs won't cause extra current to flow.

If you have resistors pulling inputs high and switches pulling them low, there will be an increased current when the buttons are pressed, but that does not flow through the microcontroller.
 

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
Keypad-arduino-circuit.png

was thinking of something like this, no resisttors just straight hook up. just going to make a 5 * 6 matrix so 11 wires
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
That will only work if you enable the internal pull-up resistors. See Here.

Yes, they will increse device dissipation when puled low against them. However it will only be to the tune of about 1mW per pin.
 

donkey

Feb 26, 2011
1,301
Joined
Feb 26, 2011
Messages
1,301
steve how would I get the most buttons without using the analog pins?
every schematic I see wants to use the analog pins to read a resistor to calculate a value thus representing a button. I am hoping to figure out how to use just the digital pins and get about 30 buttons, which I can press 2 at the same time. I have just converted to the leornardo as it is easier to make a joystick from but it only has 12 I/o pins and 7 analog, don't ask why I want all 7 analogs, I just do
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
You can arrange the switches in a matrix and read them whilst scanning the matrix, or you can use something like a 74HC165 that will allow you to read in as many inputs as you desire, using only 3 pins.
 
Top