Pages: 1 2 [3]   Go Down
Author Topic: Help with 2x2 matrix button board  (Read 1468 times)
0 Members and 1 Guest are viewing this topic.
Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you remove the diode and replace with jumper (or better would be  1-to-5k resistor ) , you can do without the external pull-down resistor and wire the switches between the arduino pin and Gnd.
Logged

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In that case your hardware test code would be simply like this:

Code:
// Button sense
const int button1 = A1;  // or whichever you wire to
const int button2 = A2;
const int button3 = A3;
const int button4 = A4;

void setup()
{
// Button sense
pinMode(button1, INPUT_PULLUP);
//pinMode(button2, INPUT_PULLUP);
//pinMode(button3, INPUT_PULLUP);
//pinMode(button4, INPUT_PULLUP);
}
void loop()
{
Serial.print( digitalRead(button1));  Serial.print("\t");
//Serial.print( digitalRead(button2)); Serial.print("\t");
//Serial.print( digitalRead(button3)); Serial.print("\t");
//Serial.print( digitalRead(button4));
Serial.println();
delay(250);
}
« Last Edit: January 30, 2013, 07:42:04 pm by johncc » Logged

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Shouldn't the input pins be digital and not analog?

And the switches should go from the digital pin to GND when pressed, yes?
Logged

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Shouldn't the input pins be digital and not analog?
Any pin (including "analog pin") can be used as digital. 

Quote
And the switches should go from the digital pin to GND when pressed, yes?

Yes, they are wired with one side to the aruduino pin, and the other side to GND.
Logged

Pages: 1 2 [3]   Go Up
Jump to: