Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #15 on: January 30, 2013, 05:57:06 pm » |
Time to post again the entire code with your changes 
|
|
|
|
|
Logged
|
|
|
|
|
Temple, Texas
Offline
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #16 on: January 30, 2013, 06:15:14 pm » |
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: 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
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #17 on: January 30, 2013, 06:46:51 pm » |
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
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #18 on: January 30, 2013, 06:50:33 pm » |
I don't get these switches! They are different, I've never used 2 pin ones.
Picture attached
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #19 on: January 30, 2013, 06:53:36 pm » |
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
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #20 on: January 30, 2013, 06:54:52 pm » |
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
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #21 on: January 30, 2013, 06:55:02 pm » |
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
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #22 on: January 30, 2013, 06:56:23 pm » |
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
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #23 on: January 30, 2013, 06:59:38 pm » |
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
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #24 on: January 30, 2013, 07:00:26 pm » |
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
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #25 on: January 30, 2013, 07:04:58 pm » |
So I set it up like this? 
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 334
Posts: 36433
Seattle, WA USA
|
 |
« Reply #26 on: January 30, 2013, 07:05:34 pm » |
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
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #27 on: January 30, 2013, 07:07:33 pm » |
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
Sr. Member
Karma: 14
Posts: 354
|
 |
« Reply #28 on: January 30, 2013, 07:24:53 pm » |
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
God Member
Karma: 4
Posts: 994
I LOVE THIS STUFF!!!!
|
 |
« Reply #29 on: January 30, 2013, 07:25:49 pm » |
Well I could remove the diodes
|
|
|
|
|
Logged
|
Accelerate to 88 miles per hour.
|
|
|
|
|