I'm starting in Arduino and I want to expand outputs with 8574 I2c module.
When compiling the code it appears: 'class PCF8574' has no member named 'pinMode'
For what is this?
I appreciate information
The Code:
#include "Arduino.h"
#include "PCF8574.h"
PCF8574 pcf8574(0x20);
void setup(){
pcf8574.begin();
pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P1, OUTPUT);
pcf8574.pinMode(P2, OUTPUT);
pcf8574.pinMode(P3, OUTPUT);
pcf8574.pinMode(P4, OUTPUT);
pcf8574.pinMode(P5, OUTPUT);
pcf8574.pinMode(P6, OUTPUT);
pcf8574.pinMode(P7, OUTPUT);
}
}
void loop(){
pcf8574.digitalWrite(P0, HIGH);
delay(1500);
pcf8574.digitalWrite(P1, HIGH);
}
Then start with the examples coming with the library.
Thanks for answer. I've tried with the libraries but still the error
Which library do you use and how did you install the library ?
Where do you get that pinMode is part of the 8574 scheme of things?
I saw its use in a library
The same one that you installed?
Yes, I even try to compile the library ande the error appear
Koepel
May 18, 2022, 4:36pm
11
OK.
Because I'm a Nice Guy, I installed that library and Copy & Pasted that sketch and there is a brace error, and I omitted the arduino.h Include.
And it Compiled.
#include "PCF8574.h"
PCF8574 pcf8574(0x20);
void setup()
{
pcf8574.begin();
pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P1, OUTPUT);
pcf8574.pinMode(P2, OUTPUT);
pcf8574.pinMode(P3, OUTPUT);
pcf8574.pinMode(P4, OUTPUT);
pcf8574.pinMode(P5, OUTPUT);
pcf8574.pinMode(P6, OUTPUT);
pcf8574.pinMode(P7, OUTPUT);
}
void loop()
{
pcf8574.digitalWrite(P0, HIGH);
delay(1500);
pcf8574.digitalWrite(P1, HIGH);
}
runaway_pancake:
#include "PCF8574.h"
PCF8574 pcf8574(0x20);
void setup()
{
pcf8574.begin();
pcf8574.pinMode(P0, OUTPUT);
pcf8574.pinMode(P1, OUTPUT);
pcf8574.pinMode(P2, OUTPUT);
pcf8574.pinMode(P3, OUTPUT);
pcf8574.pinMode(P4, OUTPUT);
pcf8574.pinMode(P5, OUTPUT);
pcf8574.pinMode(P6, OUTPUT);
pcf8574.pinMode(P7, OUTPUT);
}
void loop()
{
pcf8574.digitalWrite(P0, HIGH);
delay(1500);
pcf8574.digitalWrite(P1, HIGH);
}
It's strange I copied it without that line and still the error
Koepel
May 18, 2022, 9:00pm
14
h o w d i d y o u i n s t a l l t h e l i b r a r y ?
What version of Arduino IDE do you have?
1.18.13
And I d/l'd the ZIP file and C&P'd into the Arduino/libraries.
What if there were two different libraries but both have a PCF8574.h of their own, same in name only?
That setch does not make sense at all. What is it said to do?
Look for an I2C scanner sketch. It should show how this chip really can be used.