chipKIT® Development Platform

Inspired by Arduino™

Keypad works with arduino uno but not with max 32?

Created Tue, 10 Sep 2013 15:12:58 +0000 by psyoptica


psyoptica

Tue, 10 Sep 2013 15:12:58 +0000

This is my first experience with chipkit max 32 board and I understand that the digital outputs works the same way as the arduino output ports. I'm trying to interface a 4x3 keypad which worked fine with the uno board but there seems to be something wrong If I use it with the max32 board with same pin configuration as on UNO. The max32 board continuously displays the '#' key even when no key is pressed. When I hold and press a key, that key is display but when i release the key, the same # keeps on displaying at the same time the rx led keeps on blinking.

This is my pin assembly.

pins[1 , 2 , 3 , 4 , 5, 6, 7] = [R1, R2, R3, R4, C3, C2, C1]

This is the code I'm using:

#include <Keypad.h> //needs to be in the library folder (Arduino/Libraries)

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] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

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

void setup(){
Serial.begin(9600); //initialise the serial port (9600 baud)
}

void loop(){
char key = keypad.getKey();

if (key != NO_KEY){
Serial.println(key); //print to serial the key that has been pressed
}
}

majenko

Wed, 11 Sep 2013 09:22:37 +0000

Can you point me to the copy of the Keypad library you are using?

Edit: If it's the one on the Arduino Playground, that one makes extensive use of the pull-up resistors on the IO pins. On the MAX32 not all the pins have pull-up resistors, so you will have to select your pins carefully (on the MX1 and MX2 based boards, like the DP32 and the Fubarino Mini all pins have pull-ups).

Check the MAX32 user manual for the list of pins, and only use pins that have change notification (labeled as CNxx) for the keypad.

Edit 2: Actually, I am not sure if the CN definitions were ever added to the MAX32 board definitions. I'll look into it.


majenko

Wed, 11 Sep 2013 09:46:52 +0000

Nope, the Change Notification definitions had never been added. I don't have a MAX32, so I am unable to test it, but here is a new Board_Data.c file for you - extract it and copy it into hardware/pic32/variants/Max32 and see if it works. You will still have to select your pins carefully though. Here's a list of pins you can use with pull-ups:

4 10, 16, 17, 18, 19 29 39 43, 47 52, 53, 54, 55, 56, 57, 58, 59 69 75, 76, 77


psyoptica

Wed, 11 Sep 2013 11:50:51 +0000

I used pins 3 5 6 and 7 of the keypad with pull ups to the pins you mentioned but it doesn't work. I already have a file Board_Data.c in my hardware folder. I think by using the library which is intended for arduino in causing problems.


majenko

Wed, 11 Sep 2013 12:47:26 +0000

You must replace the Board_Data.c file in your hardware folder with the one in the zip file.

You must connect your keypad only to the pins in that list - using other pins will not work. Those are the only pins that have integral pull-up resistors built in, and hence the only pins that

pinMode(x, INPUT_PULLUP);

will work on.

Disconnect your keypad from it's current pins and connect it to ones that I have listed above.


psyoptica

Wed, 11 Sep 2013 13:14:32 +0000

I did replace Board_Data.c file with the one you provided. I also used the pins you mentioned but the problem remains. Are those CN pins in the max 32 board that you mentioned?

I appreciate your help manjenko!


majenko

Wed, 11 Sep 2013 13:32:35 +0000

Do you have a multimeter handy?

Can you do me a favour and test the changes I made in the Board_Data.c file?

If you set all of those listed pins as INPUT_PULLUP in a little sketch you should find that they all read around 3.2V with your multimeter.


psyoptica

Wed, 11 Sep 2013 16:50:40 +0000

The output voltages read 3.82. Is that normal? I'm using pins 4,77,76,75 for rows and pins 29, 39 and 43 for col.


majenko

Wed, 11 Sep 2013 22:17:51 +0000

That all sounds ok. I can't see why it wouldn't work.


kaaasap

Wed, 16 Oct 2013 15:47:21 +0000

cancel post


Hisham_Mahrous

Wed, 07 Sep 2016 11:17:32 +0000

I'm facing the same issue with uC32 board and I'm using Arduino IDE 1.6.9 and using the chipkit plug-in I'm using Keypad library downloaded from official Arduino website, and this the code I'm testing with:

#include <Keypad.h>

const byte ROWS = 4; // four rows
const byte COLS = 4; // four columns
char keys [ROWS] [COLS] = {
  {'1', '2', '3', 'S'},
  {'4', '5', '6', '+'},
  {'7', '8', '9', '-'},
  {'R', '0', '.', 'E'}
};
byte rowPins[ROWS] = {7, 6, 5, 4}; //connect keypad ROW1, ROW2, ROW3, ROW4 to these arduino pins
byte colPins[COLS] = {17, 16, 15, 14}; //connect keypad COL1, COL2, COL3, COL4 to these arduino pins

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

void setup(){
  Serial.begin(9600);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(17, INPUT_PULLUP);
}
  
void loop(){
  char key = keypad.getKey();
  
  if (key){
    Serial.println(key);
  }
}

could anyone help me ?


majenko

Thu, 08 Sep 2016 10:03:49 +0000

The Arduino Keypad library relies on the IO pins the keypad is connected to providing internal pullups. On the Uno32, uC32 and MAX32 (in fact on any board not based on the newer PPS enabled chips) not all the pins have pullups.

You have to check the manual for which pins are "Change Notification" pins (CNx) and limit yourself to only using those pins. Either that or use a board based around one of the newer PPS chips - i.e., MX1xx, MX2xx, MX[3/4]70, or any MZ board.