Pages: 1 [2] 3   Go Down
Author Topic: Help with 2x2 matrix button board  (Read 1483 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

Time to post again the entire code with your changes smiley
Logged

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

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:
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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46090
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Picture attached


* IMG_20130130_174911.jpg (848.06 KB, 2048x1536 - viewed 14 times.)
Logged

Accelerate to 88 miles per hour.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46090
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Accelerate to 88 miles per hour.

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

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?
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Accelerate to 88 miles per hour.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46090
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So I set it up like this?

Logged

Accelerate to 88 miles per hour.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 46090
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Accelerate to 88 miles per hour.

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

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
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1000
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I could remove the diodes
Logged

Accelerate to 88 miles per hour.

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