Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ESP8266WiFi.h>
- #include "PCF8574.h"
- PCF8574 pcf8574(0x38);
- class PinReader {
- public:
- PCF8574 *expander;
- void read();
- };
- void PinReader::read() {
- Serial.println("Pin state inside init: " + String(this->expander->digitalRead(P6)));
- }
- void setup() {
- Serial.begin(115200);
- Serial.println();
- PinReader reader = PinReader();
- pcf8574.pinMode(P6, INPUT);
- if (pcf8574.begin()) {
- Serial.println("Begin success");
- } else {
- Serial.println("Begin FAIL");
- }
- delay(100);
- reader.expander = &pcf8574;
- reader.read();
- Serial.println("Pin state outside init: " + String(pcf8574.digitalRead(P6)));
- }
- void loop() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement