button pad

I want to know what those little rectangles with a line at the end of it means.

shown here

http://www.sparkfun.com/commerce/images … 3-02-L.jpg

Does it stand of a resistor or a signal diode?

Thank you

wow sorry just noticed wrong area to post.

probably a diode. why don’t you find the schematic, that might be a tad more helpful than a guess.

dont really get it, kinda new to this.

im trying to figure out exactly how the switch should be set up

Have you read through the [link in the product desripction? :wink:](Keyboard Matrix Help)

yeh lol, i think im not seeing right. i keep imagining a tactical switch, with the pull up/pull down.

Those would be diodes according to the [keypad schematic.](http://www.sparkfun.com/datasheets/Components/Buttons/Button_Pad_Breakout.pdf)

ok i got the signal diode and soldered them on, but when i test out the pad my input is random 1 or 0, but when i press is 0.

the only one that works correctly is Switch 1 its 1 then when pressed 0.

i dont know whats wrong

heres my code

int switchPin1 = 1;
int switchPin2 = 2;            
int switchPin3 = 3;
int switchPin4 = 4;
int val1;
int val2;
int val3;
int val4;

void setup()                    
{
  Serial.begin(9600);   
  pinMode(switchPin1, INPUT);  
  pinMode(switchPin2, INPUT);   
  pinMode(switchPin3, INPUT);  
  pinMode(switchPin4, INPUT);
}
void loop()                     
{
  val1 = digitalRead(switchPin1);
  Serial.print("VALUE 1 is   ");
  Serial.println(val1);
  delay(100);
  
  val2 = digitalRead(switchPin2);
  Serial.print("VALUE 2 is   ");
  Serial.println(val2);
  delay(100);

  val3 = digitalRead(switchPin3);
  Serial.print("VALUE 3 is   ");
  Serial.println(val3);
  delay(100);
 
  val4 = digitalRead(switchPin4);
  Serial.print("VALUE 4 is   ");
  Serial.println(val4);
  delay(100);
 }

i test each val seperatly

You need pullups on your input pins. Either regular resistors (say 1K-10K), one from each input to your supply, or on-chip pullups if your micro has them. The pullup will ensure that an input that isn’t connected to ground thru a switch will always be a 1.

n1ist:
You need pullups on your input pins. Either regular resistors (say 1K-10K), one from each input to your supply, or on-chip pullups if your micro has them. The pullup will ensure that an input that isn’t connected to ground thru a switch will always be a 1.

thanks for the info, i tested a little and its very weird whats going on now haha.

I put 10k resistors on each input. no change but i realize that if i have my finger on the #1 inputs resistor wire, val2-4 work perfect. and val1 is a constant unless i take out the resistors, which causes val2-4 to go bad.

any ideas?

Thank you

Make sure you have soldered the diodes in the correct orientation…

FartingMonkey92:
Make sure you have soldered the diodes in the correct orientation…

im pretty sure they are correct,

dont you have to line up the bold black strip of the diode with the white strip on the board

dont you have to line up the bold black strip of the diode with the white strip on the board

Correct. Do you have any part of your circuit on a breadboard?

(ie. if you press on something, it could be causing an intermittent break)

It seems to me that you want to have pull-downs instead of pull-ups on the input pins (JP5-JP8 on the schematic). Then the microcontroller will loop through the rows (JP1-JP4) one at time.

  pinMode(switchPin1, OUTPUT); // JP1
  pinMode(switchPin2, OUTPUT); // JP2  
  pinMode(switchPin3, OUTPUT); // JP3
  pinMode(switchPin4, OUTPUT); // JP4
  pinMode(switchPin5, INPUT); // JP5
  pinMode(switchPin6, INPUT); // JP6  
  pinMode(switchPin7, INPUT); // JP7 
  pinMode(switchPin8, INPUT); // JP8 

  // you need to create a loop that processes each of the four rows
  // here is the pseudo code for a row (row 1, in this case)

  Set switchPin1, HIGH, switchPin2..3, LOW

  Look for a logic 1 on any of the four columns (switchPin5..8).

  A logic 1 indicates a key press -- note that up to four keys in that row can be pressed at a time and can be resolved.

  Record any keypresses and move on to the next row

The keyboard scan approach is a pretty common way to read a keypad, although you could get creative and use a few resistors and the ADC in your chip to read the keypad as well. Using this approach you use a 2.2k resistor from VDD to JP1, a 4.7k from VDD to JP2, a 10k from VDD to JP3, and 22k from VDD to JP4. You will still need pull downs from JP5-JP8 to VSS. The resistors are always connected to the keypad and your code reads the voltage on each of the input pins (JP5-JP8) in turn. The value that the ADC reports is then compared to a table of values (a range of values) that indicate which switches have been pressed. Since the voltage is additive, multiple switch presses can be detected using this method as well.

In my projects, I prefer scanning the keypad row by row, but the resistor ladder network approach is interesting and only requires four input pins (although they need to be ADC inputs).

thanks for the info, i will keep testing figure this out

will report back

I have got everything in working order so far :slight_smile:

I used ridens schematic and i couldn’t have done it without everyones help all the info combined made it work haha.

heres my code for anyone interested or if any future people need it.

int switchPin1 = 1;
int switchPin2 = 2;            
int switchPin3 = 3;
int switchPin4 = 4;
int switchPin5 = 5;
int switchPin6 = 6;
int switchPin7 = 7;
int switchPin8 = 8;
int val1;
int val2;
int val3;
int val4;

void setup()                    
{
  Serial.begin(9600); 
  
  pinMode(switchPin1, OUTPUT); // JP1
  pinMode(switchPin2, OUTPUT); // JP2 
  pinMode(switchPin3, OUTPUT); // JP3
  pinMode(switchPin4, OUTPUT); // JP4
  pinMode(switchPin5, INPUT); // JP5
  pinMode(switchPin6, INPUT); // JP6 
  pinMode(switchPin7, INPUT); // JP7
  pinMode(switchPin8, INPUT); // JP8 
}
void loop()                     
{
  digitalWrite (switchPin1,HIGH);
  digitalWrite (switchPin2,HIGH);
  digitalWrite (switchPin3,HIGH);
  digitalWrite (switchPin4,HIGH);
  
  val1 = digitalRead(switchPin5);
  Serial.print("VALUE 1 is   ");
  Serial.println(val1);
  delay(100);        //so microcontroller doesnt overload
  
  val2 = digitalRead(switchPin6);
  Serial.print("VALUE 2 is   ");
  Serial.println(val2);
  delay(100);
  
  val3 = digitalRead(switchPin7);
  Serial.print("VALUE 3 is   ");
  Serial.println(val3);
  delay(100);
  
  val4 = digitalRead(switchPin8);
  Serial.print("VALUE 4 is   ");
  Serial.println(val4);
  delay(100);
}

if any future cases come up i will defiantly post haha.

Thank you