Go Down

Topic: 4x3 Keypad from Sparkfun (Read 6491 times) previous topic - next topic

Angelsbane72

I've tried many times in getting this basic 3x4 0-9*# keypad device to work.

It has 9 pins, 7 of which I know are to be utilized in connecting to Arduino pins. (ignoring the first and last pins)

By creating a row vs column schematic I've seen, I had determined that:

Keypad Pin 1 - col 1
Keypad Pin 2 - row 0
Keypad Pin 3 - col 0
Keypad Pin 4 - row 3
Keypad Pin 5 - col 2
Keypad Pin 6 - row 2
Keypad Pin 7 - row 1

I am using an Arduino MEGA, can I connect these to digital pins 38-44?
I tried doing so and when I followed the hello keypad tutorial, I couldn't enter any keys to show up in the serial monitor.
 
Any help would be greatly appreciated

larryd

Please:
Show an image of how you are wired to the Arduino.
Attach "your" sketch for us to see (use code tags).
No technical PMs.
The last thing you did is where you should start looking.

Angelsbane72

The sketch I am working with is as follows:

/* @file HelloKeypad.pde
*/
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'},
};
byte rowPins[ROWS] = {43, 38, 39, 41};
//Can I use digital pins on Ard MEGA? I'd like to use Digital pins 38-44 since I have LCDs connected as well//

byte colPins[COLS] = {42, 44, 40};

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}
 
void loop(){
  char key = keypad.getKey();
 
  if (key){
    Serial.println(key);
  }
}

larryd

Do you have a image of the wiring?
Code: [Select]
void loop(){
  char key = keypad.getKey();

  if (key != NO_KEY){
    Serial.println(key);
  }
}
No technical PMs.
The last thing you did is where you should start looking.

Angelsbane72

Here is my wiring, simply pins 1-7 on keypad to 38-44 on digital pins of arduino mega

Angelsbane72

The only keys that show up in the serial monitor are 4,7, and *

larryd

Assuming you have the right pads for cols and rows:

The red wires going into the green PCB are not soldered to the top layer PCB pads.
It looks to me there are no plated thru holes.
No technical PMs.
The last thing you did is where you should start looking.

larryd

Yes, you need to solder those wires to the pads.
No technical PMs.
The last thing you did is where you should start looking.

Angelsbane72

So using the products data sheet, I was able to get the correct wiring for the rows/columns.
However, although the key presses show up in the serial monitor, they stop appearing after a while.

Also, the red wires are touching the metal pin holes in the keypad, so there is a connection there without solder

larryd

You need to solder the wires to the pads.
No technical PMs.
The last thing you did is where you should start looking.

JoshD

If you don't want to solder wires directly to the pads, you could also use a female header.  That way you can still "unplug" it when you're done and use it in another circuit later.

Angelsbane72

Ok, I will do that.

My goal is to use a code I'm currently tinkering with to accept user input from the keypad.:

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
 // set up the LCD's number of columns and rows:
 lcd.begin(16, 2);
 // Print a message to the LCD.
 lcd.print("Select Part Family using Keypad:");
 // set the cursor to column 0, line 1
 // (note: line 1 is the second row, since counting begins with 0)
 lcd.setCursor(0, 1);
 lcd.print("1 = CFM // 2 = PRT-X // 3 = PRT-Y");
 delay(750);
}

void loop() {
 // scroll 13 positions (string length) to the left
 // to move it offscreen left:
 for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
   // scroll one position left:
   lcd.scrollDisplayLeft();
   // wait a bit:
   delay(500);
 }
 // delay at the end of the full loop:
 delay(0);
}

Once the user presses a number corresponding to a part, I'd like the program to ask for user confirmation.
Then, and only then, once the user presses a start push button, I'd like a servo I have to begin moving.

I have a servo code I've written, but I;m not sure how to get to that point.

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Angelsbane72

Yes, I've seen that tutorial.
The issue is that I'm not familiar enough with the programming language to be able to code what I want to happen when a key is pressed.

Additionally, I am forgoing the keypad and using buttons on an LCD shield I have wired up.
However, I am unsure as to how to account for the analog pin for the 5 buttons on the shield.
I can't seem to find where to connect to on the shield, and once connected, how to code it into my program that the buttons will be utilized.

raschemmel

Quote
Additionally, I am forgoing the keypad and using buttons on an LCD shield I have wired up.
However, I am unsure as to how to account for the analog pin for the 5 buttons on the shield.
I can't seem to find where to connect to on the shield, and once connected, how to code it into my program that the buttons will be utilized.
Are you saying you don't have the schematic or you don't understand the concepts of a voltage divider or an array ?

Quote
I can't seem to find where to connect to on the shield
This means what ? (you don't have the code which identifies the analog input pin or you don't have the schematic which shows the same thing ?

I'm really not understanding what the problem is here. Both the code and the schematic identify which analog input pin is used.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up