Go Down

Topic: Help with 2x2 matrix button board (Read 2349 times) previous topic - next topic

johncc

Time to post again the entire code with your changes :)

johncc

We are working on just the buttons right now, we will leave the LEDS for later.

If your version has the so-called "isolation diodes" then we must reverse the polarity of the sense:

Code: [Select]
void setup()
{
pinMode(buttonMatrix1, INPUT);   // Button sense
pinMode(buttonMatrix2, INPUT);   // external pull-down may be required
pinMode(buttonMatrix3, INPUT);
pinMode(buttonMatrix4, INPUT);

pinMode(SwitchPin, OUTPUT);     // Button Common 
digitalWrite(SwitchPin, HIGH);
}
void loop()
{
Serial.print(analogRead(buttonMatrix1));
Serial.print("\t");
Serial.print(analogRead(buttonMatrix2));
Serial.print("\t");
Serial.print(analogRead(buttonMatrix3));
Serial.print("\t");
Serial.println(analogRead(buttonMatrix4));
delay(200);
}

Cheers,
John

PaulS

I'm always amazed at people that take an action based on one reading, then take another reading and print it, and don't understand that the two readings can be different.

Those appear to be regular digital switches on that board. Why are you using analogRead() to read digital switches?

How about posting a picture showing how you have connected that to the Arduino?

funkyguy4000

I don't get these switches!
They are different, I've never used 2 pin ones.

Picture attached
Accelerate to 88 miles per hour.

PaulS

Quote
They are different, I've never used 2 pin ones.

Every switch I've ever seen had just two pins. Have you used a multimeter to see how those switches actually work?

funkyguy4000

I haven't, unfortunately I left my multimeter back home from winter break.

I mean, I've only ever used push buttons.  
I still don't get why when I press one button, all of them respond

EDIT: Respond as the same button I mean.
Accelerate to 88 miles per hour.

johncc


I don't get these switches!
They are different, I've never used 2 pin ones.


Did you ever run successfully the sketch that you had copy/pasted off the 'net before you started changing it?

funkyguy4000

No, there aren't many sketches for just the 2x2 matrix. 
I have had it working to the point where it lights up, and then I press a button and all the lights change to the specified, but its always the same color and doesn't correspond to which button is pressed
Accelerate to 88 miles per hour.

PaulS

Quote
I still don't get why when I press one button, all of them respond

EDIT: Respond as the same button I mean.

Well, clearly you don't have them connected right. I would expect the switches to be wired one side to ground and one side to a digital pin, with the pullup resistor on that pin enabled. Press the switch to have the pin go LOW.

johncc


No, there aren't many sketches for just the 2x2 matrix. 
I have had it working to the point where it lights up, and then I press a button and all the lights change to the specified, but its always the same color and doesn't correspond to which button is pressed


Well, it appears you got that code from here http://www.aarongoselin.com/active-posts/28-using-sparkfuns-2x2-rgb-led-button-pad-with-an-arduino
(Not that it's that great as PaulS has noted)

But again, did it work before you started changing it?

Cheers,
John

funkyguy4000

Accelerate to 88 miles per hour.

PaulS

Quote
As I wrote up-thread his version may have the "isolation diodes" in which case he would need to go the other way around, with pulldown resistors...

A good reason to have a multi-meter. OP, hit the nearest Radio Shack (or equivalent) before you fry something.

funkyguy4000

Haha, okay.  I'll get in the lab tomorrow.  I need to get to my MATLAB homework anyway.
To make sure we are clear, what exactly am I looking for?
Accelerate to 88 miles per hour.

johncc


So I set it up like this?




Yeah.  Unless you can figure out that your version does not have the isolation diodes, in which case it could be simpler..


And maybe just start with 1 button
get it Working
...
and then 1 led
get it Working
...
and then more leds
working
... etc

funkyguy4000

Accelerate to 88 miles per hour.

Go Up