GithubHelp home page GithubHelp logo

Comments (6)

xreef avatar xreef commented on June 7, 2024

Hi jhengstermann,
to set the initial value to HIGH you must set pin to INPUT_PULLUP.
Bye Renzo

from pcf8574_library.

jhengstermann avatar jhengstermann commented on June 7, 2024

I think there is still a problem, or i'am misunderstanding something
I've added a couple of debug lines to the digitalReadAll function and this is the output:

10:39:37.003 -> W: 0 R ALL: 1 R Down: 0R Up: 1
10:39:37.003 -> Set pin 1 as 2
10:39:37.003 -> W: 0 R ALL: 11 R Down: 0R Up: 11
10:39:37.003 -> Set pin 2 as 2
10:39:37.003 -> W: 0 R ALL: 111 R Down: 0R Up: 111
10:39:37.003 -> Set pin 3 as 2
10:39:37.003 -> W: 0 R ALL: 1111 R Down: 0R Up: 1111
10:39:37.003 -> Set pin 4 as 2
10:39:37.003 -> W: 0 R ALL: 11111 R Down: 0R Up: 11111
10:39:37.003 -> Set pin 5 as 2
10:39:37.003 -> W: 0 R ALL: 111111 R Down: 0R Up: 111111
10:39:37.003 -> Set pin 6 as 2
10:39:37.003 -> W: 0 R ALL: 1111111 R Down: 0R Up: 1111111
10:39:37.003 -> Set pin 7 as 2
10:39:37.003 -> W: 0 R ALL: 11111111 R Down: 0R Up: 11111111
10:39:37.003 -> Read from buffer
10:39:37.003 -> Data ready
10:39:37.003 -> Input 11111111Buffer value 0
10:39:37.003 -> Buffer hight value readed set readed 0
10:39:37.003 -> Return value: 00000000

you can see that the byte read from i2c (Input) is B11111111, which is correct, because the pins are all high on startup.
But the return value is all 00000000

from pcf8574_library.

xreef avatar xreef commented on June 7, 2024

Hi,
can you post your code.
Thanks Renzo

from pcf8574_library.

jhengstermann avatar jhengstermann commented on June 7, 2024

here it is:

#define GPIO_EXP_ADR 0x38

#include <Arduino.h>
#include "PCF8574.h"

PCF8574 ioX_pcf8574(GPIO_EXP_ADR);

void setup() {
	Serial.begin(115200);
	Serial.println();
	delay(10);

  	ioX_pcf8574.begin();
	delay(10);

	for (int i=0; i<8; i++) {
		ioX_pcf8574.pinMode(i, INPUT_PULLUP);
	}
	delay(10);

	ioX_pcf8574.digitalReadAll();
}

void loop() {
}

and in PCF8574.cpp i just added these print statements to the end of PCF8574::DigitalInput PCF8574::digitalReadAll(void)

DEBUG_PRINT(digitalInput.p0);
DEBUG_PRINT(digitalInput.p1);
DEBUG_PRINT(digitalInput.p2);
DEBUG_PRINT(digitalInput.p3);
DEBUG_PRINT(digitalInput.p4);
DEBUG_PRINT(digitalInput.p5);
DEBUG_PRINT(digitalInput.p6);
DEBUG_PRINTLN(digitalInput.p7);

im using an ESP8266.

from pcf8574_library.

xreef avatar xreef commented on June 7, 2024

Hi jhengstermann,
I spent hours trying to debug your problem, couldn't figure out why it happened.
But in the end I didn't notice the most obvious thing.

You put the begin of the pcf8574 before the pins initialization: P.

Bye Renzo

from pcf8574_library.

jhengstermann avatar jhengstermann commented on June 7, 2024

yeah thanks 🙏

from pcf8574_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.