arduino keypad i2c library having issues with arduino 2.0

http://arduino.cc/playground/Main/I2CPortExpanderAndKeypads

this library seems to be giving me alot of issue, I can't verify it.
is there anyone with a solution for this?

In the future, when 2.0 is released, I'll try to compile the library, and see what issues there are.

Meanwhile, you might want to tell us what version you are actually using.

I made a typo for god sake. It's 1.0. Why is everyone in this forum so sarcastic.

Why is everyone in this forum so sarcastic.

Please read the comic Dilbert to understand engineers and their humor :wink:

With the move to 1.0 some internals have changed - http://arduino.cc/en/Main/ReleaseNotes -

this library seems to be giving me alot of issue, I can't verify it.

Can you state the nature of the issues?
Please post your code, tell what you expect and what you got?

A quick look at the lib seems to look OK to me.

So, on that page is some code - i2ckeypad.h, i2ckeypad.cpp, and i2ckeypad.pde. That last one should be enough of a clue that the page has not been updated for 1.0.

You have two choices. You can use that code with 0023 or earlier, or you can make the needed changes to make it work with 1.0. It took me less than 5 minutes.

WConstants.h no longer exists. Use Arduino.h instead, but move it outside the (no longer needed) extern "C" block.

The Wire.receive() function was renamed to Wire.read(), and the Wire.send() function was renamed to Wire.write().

hi guys I got this library from the playground, i posted this topic last week, but for some reasons the admin deleted or something.
http://arduino.cc/playground/Main/I2CPortExpanderAndKeypads

after I added this file in, which is not even fully compatible with v1.0, I managed to edit some parts of it to make it work such as Wconstant.h and wire.send, wire.receive.

it looks like this:

/*

  • i2ckeypad.cpp v0.1 - keypad/I2C expander interface for Arduino
  • Copyright (c) 2009 Angel Sancho angelitodeb@gmail.com
  • All rights reserved.
  • Original source from keypad v0.3 of Mark Stanley mstanley@technologist.com
  • (Arduino Playground - KeypadTutorial)
  • LICENSE

  • This program is free software: you can redistribute it and/or modify
  • it under the terms of the GNU General Public License as published by
  • the Free Software Foundation, either version 3 of the License, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details.
  • You should have received a copy of the GNU General Public License
  • along with this program. If not, see http://www.gnu.org/licenses/.
  • EXPLANATION

  • This library is designed for use with PCF8574, but can possibly be
  • adapted to other I2C port expanders
  • Wiring diagrams for PCF8574 and 4x3 keypad can be found under
  • examples directory. Library runs correctly without cols pull-up
  • resistors but it's better to use it
  • You can change pin connections between PCF8574 and keypad under
  • PIN MAPPING section below
  • IMPORTANT! You have to call Wire.begin() before init() in your code
  • ... and sorry for my poor english!
    */

#include "i2ckeypad.h"
#include <Wire.h>

extern "C" {

}

#include "Arduino.h"
/*

  • PIN MAPPING
  • Here you can change your wire mapping between your keypad and PCF8574
  • Default mapping is for sparkfun 4x3 keypad
    */

#define COL0 2 // P2 of PCF8574, col0 is usually pin 3 of 4x3 keypads
#define COL1 0 // P0 of PCF8574, col1 is usually pin 1 of 4x3 keypads
#define COL2 4 // P4 of PCF8574, col2 is usually pin 5 of 4x3 keypads
#define COL3 7 // sorry, don't have a 4x4 keypad to try it
#define ROW0 1 // P1 of PCF8574, row0 is usually pin 2 of 4x3 keypads
#define ROW1 6 // P6 of PCF8574, row1 is usually pin 7 of 4x3 keypads
#define ROW2 5 // P5 of PCF8574, row2 is usually pin 6 of 4x3 keypads
#define ROW3 3 // P3 of PCF8574, row3 is usually pin 4 of 4x3 keypads

/*

  • KEYPAD KEY MAPPING
  • Default key mapping for 4x4 keypads, you can change it here if you have or
  • like different keys
    */

const char keymap[4][5] =
{
"123A",
"456B",
"789C",
"*0#D"
};

/*

  • VAR AND CONSTANTS DEFINITION. Don't change nothing here

*/

// Default row and col pin counts
int num_rows = 4;
int num_cols = 3;

// PCF8574 i2c address
int pcf8574_i2c_addr;

// Current search row
static int row_select;

// Current data set in PCF8574
static int current_data;

// Hex byte statement for each port of PCF8574
const int hex_data[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};

// Hex data for each row of keypad in PCF8574
const int pcf8574_row_data[4] =
{
hex_data[ROW1] | hex_data[ROW2] | hex_data[ROW3] |
hex_data[COL0] | hex_data[COL1] | hex_data[COL2] | hex_data[COL3],
hex_data[ROW0] | hex_data[ROW2] | hex_data[ROW3] |
hex_data[COL0] | hex_data[COL1] | hex_data[COL2] | hex_data[COL3],
hex_data[ROW0] | hex_data[ROW1] | hex_data[ROW3] |
hex_data[COL0] | hex_data[COL1] | hex_data[COL2] | hex_data[COL3],
hex_data[ROW0] | hex_data[ROW1] | hex_data[ROW2] |
hex_data[COL0] | hex_data[COL1] | hex_data[COL2] | hex_data[COL3],
};

// Hex data for each col of keypad in PCF8574
int col[4] = {hex_data[COL0], hex_data[COL1], hex_data[COL2], hex_data[COL3]};

/*

  • CONSTRUCTORS
    */

i2ckeypad::i2ckeypad(int addr)
{
pcf8574_i2c_addr = addr;
}

i2ckeypad::i2ckeypad(int addr, int r, int c)
{
pcf8574_i2c_addr = addr;
num_rows = r;
num_cols = c;
}

/*

  • PUBLIC METHODS
    */

void i2ckeypad::init()
{
// All PCF8574 ports high
pcf8574_write(pcf8574_i2c_addr, 0xff);

// Start with the first row
row_select = 0;
}

char i2ckeypad::get_key()
{
static int temp_key;

int tmp_data;
int r;

int key = '\0';

// Search row low
pcf8574_write(pcf8574_i2c_addr, pcf8574_row_data[row_select]);

for(r=0;r<num_cols;r++) {
// Read pcf8574 port data
tmp_data = pcf8574_byte_read(pcf8574_i2c_addr);

// XOR to compare obtained data and current data and know
// if some column are low
tmp_data ^= current_data;

// Key pressed!
if(col[r] == tmp_data) {
temp_key = keymap[row_select][r];
return '\0';
}
}

// Key was pressed and then released
if((key == '\0') && (temp_key != '\0'))
{
key = temp_key;
temp_key = '\0';
return key;
}

// All PCF8574 ports high again
pcf8574_write(pcf8574_i2c_addr, 0xff);

// Next row
row_select++;
if(row_select == num_rows) {
row_select = 0;
}

return key;
}

/*

  • PRIVATE METHODS
    */

void i2ckeypad::pcf8574_write(int addr, int data)
{
current_data = data;

Wire.beginTransmission(addr);
Wire.write(data);
Wire.endTransmission();
}

int i2ckeypad::pcf8574_byte_read(int addr)
{
Wire.requestFrom(addr, 1);

return Wire.read();
}

but for some reason, it keeps telling me error, wire.send has been renamed to wire.write.
I have already changed the the line which says wire.send to wire.write, but yet it keep telling me this error.
any help will be deeply appreciated.
thanks.
and to those who ask me what kinda library im using, please just use your eyes and click on the link above, its all there.

screes2.tiff (96.2 KB)

hi guys I got this library from the playground, i posted this topic last week, but for some reasons the admin deleted or something.

Or something, I guess, because it was not deleted.

I copied the code from the playground, again. I changed WConstants.h to Arduino.h, and moved it outside the extern "C" block. I changed one occurrence of Wire.send() to Wire.write(). I changed one occurrence of Wire.receive() to Wire.read(). I changed the <i2ckeypad.h> part of the include statement in the sketch to "i2ckeypad.h". I compile, and it produces only one "error" message.

Binary sketch size: 4356 bytes (of a 30720 byte maximum)

If you are still getting errors, then there is a very good chance that you have duplicate code somewhere.

P.S. Learning to post code properly, using the # icon, would be a good thing. Otherwise, we might have to kill you.

PaulS:
Or something, I guess, because it was not deleted.

And now the admins have merged the two topics about the keypad library.

... the admin deleted or something ...

Did you forget where you put the last thread? Try to remember this one. You can subscribe to it you know.

Otherwise, we might have to kill you.

Or ignore you. If you don't follow the tips here about how to post questions:

http://arduino.cc/forum/index.php/topic,97455.0.html

would it be too much trouble for you to post the code here for me? for some reason I'm still getting the same error. I did what you said, but it still gets stuck at wire.send has been renamed wire.write.

or if possible, email me at joetsao2001@gmail.com

I'm in need of this desperatly because its for my final year project, and none of my lecturers know arduino. any help will be deeply appreciared.

Did you forget where you put the last thread? Try to remember this one. You can subscribe to it you know.

No need to subscribe, in your profile there is a list of all your posts sorted descending on the time attribute ....

Arduino Forum xxxx ;sa=showPosts where xxxx is your forum id ..

I know this is being posted well after the fact but thanks much PaulS for the changes required in i2ckeypad.h . That saved me a bunch of messing around.