Hi!
I have problem
I can't use together #include <Keypad_I2C.h> and PCF8574 expander1;
Do you know any simple solutions this problem?
I added an attachment
You have somehow installed Keypad_I2C into a system folder of the Arduino, and it is missing the Keypad library.
I think it is better to install the Arduino IDE again (in a new folder).
To install a library it is best to use the Library Manager (it is in the menu of the Arduino IDE). After that install it with a *.zip file (that is also in the menu).
If all of that is not possible, copy the new library into the "libraries" folder that is next to the folders of the projects.
Hello,
I have similar problem when I try use in one project #include <Keypad_I2C.h> and #include<PCF8574.h>. as below:
#include <PCF8574.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad_I2C.h>
#include <Keypad.h>
#define i2cAddr_KEY 0x38
#define i2cAddr_LCD 0x3F
#define i2cAddr_Exp 0x21
/-----( Declare Constants )-----/
const byte ROWS = 4;
const byte COLS = 4;
/-----( Declare Variables )-----/
PCF8574 Exp;
char keys[ROWS][COLS] = {
- {'1','2','3','A'},*
- {'4','5','6','B'},*
- {'7','8','9','C'},*
_ {'*','0','#','D'}};_
byte rowPins[ROWS] = {0,1,2,3};
byte colPins[COLS] = {4,5,6,7};
/-----( Declare objects )-----/
// set the LCD address to 0x3F for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(i2cAddr_LCD, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
Keypad_I2C kpd = Keypad_I2C(makeKeymap(keys), rowPins, colPins, ROWS, COLS, i2cAddr_KEY);
void setup() /----( SETUP: RUNS ONCE )----/
{
- Serial.begin(9600); // Used to type in characters*
- lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight*
- kpd.begin();*
- Exp.begin(i2cAddr_Exp);*
}/--(end setup )---/
void loop()
{
}
I have got errors:
In file included from D:..\Documents\Arduino\test_pcf\test_pcf.ino:5:0:
D:..\Arduino\libraries\Keypad_I2C/Keypad_I2C.h:38:17: error: expected unqualified-id before numeric constant
#define PCF8574 1 // PCF8574 I/O expander device is 1 byte wide
- ^*
D:..\Documents\Arduino\test_pcf\test_pcf.ino:17:1: note: in expansion of macro 'PCF8574'
PCF8574 Exp;
^
D:..\Documents\Arduino\test_pcf\test_pcf.ino: In function 'void setup()':
test_pcf:40: error: 'Exp' was not declared in this scope - Exp.begin(i2cAddr_Exp);*
- ^*
exit status 1
'Exp' was not declared in this scope
I need extra 8 outputs for relay module and I decided to use the expander, but libraries not work together. Have You idea what to do?
It is easier when you start a new topic. Give a link to this topic when you start a new topic.
Test with the examples (in the menu) if all the libraries work.
Tell us which libraries you have installed, and how.
Turn on the extra compiler output in the settings and show the complete compiler output.
There are more PCF8574 libraries, but this one does not go together with the Keypad_I2C library.
Could you connect the keypad directly to the Arduino board (not using I2C) ?
You could change the library and give other names to the define or class in the libraries.
Or you could try another PCF8574 library.
I tested examples each of the libraries separately and works properly.
I use this libraries:
Keypad_I2C.h
version 2.0 - PCF8575 support added by Paul Williamson
author G. D. (Joe) Young, ptw
contact "G. D. (Joe) Young" jyoung@islandnet.com
PCF8574.h
PCF8574 arduino library
author SkyWodd skywodd@gmail.com
version 2.0
link http://skyduino.wordpress.com/
The libraries was installed over import from zip.
Detailed output of compiler in attachments.
If I'm thinking correct I should make some changes in library PCF8574?
compiler_1.txt (29.8 KB)
If you want to keep these libraries, you have to change some names.
[EDIT] I have removed this paragraph. I didn't know that the Arduino Store uses version 1.8.10. Sorry for that.
For the libraries: Don't just download a library from somewhere on the internet. It could be outdated. Go to the Library Manager in the Arduino IDE and see if that library is there. If it is not, try to find it on Github.com.
Do you use this library ? arduino_keypads/Keypad_I2C at master ยท joeyoung/arduino_keypads ยท GitHub
I prefer to change the Keypad_I2C library.
Remove these two lines in the "Keypad_I2C.h":
#define PCF8574 1 // PCF8574 I/O expander device is 1 byte wide
#define PCF8575 2 // PCF8575 I/O expander device is 2 bytes wide
When you have a sketch that needs that define, replace it with 1:
// Keypad_I2C kpd( makeKeymap(keys), rowPins, colPins, ROWS, COLS, I2CADDR, PCF8574 );
Keypad_I2C kpd( makeKeymap(keys), rowPins, colPins, ROWS, COLS, I2CADDR, 1 );
The answer Keopel worked out for me.