Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

digitalRead returns wrong values ? #12

Open
chopperaddict opened this issue May 27, 2018 · 5 comments
Open

digitalRead returns wrong values ? #12

chopperaddict opened this issue May 27, 2018 · 5 comments

Comments

@chopperaddict
Copy link

I have just started using tis library, and it is great so far writing to the chip, BUT I want to be able to read its content as well, but the following code returns
1111010
1001

uint8_t input = 0; setStartupFrogs(); Serial.println("Startup setting setup"); delay(3000); //Serial.println(expander.digitalRead(3) ? "HIGH" : "LOW"); // Print button pin state input = Serial.println(expander.read(), BIN); // Read the whole pins input register Serial.println(input, BIN);
setStrartupFrogs() actually sets pins 0, 2,and 7, so I am expecting to see

10000101

assuming it maintains MSB or LSB forread and write, but these values are not correct either way around ?

Is this a known issue ?

@FernandoGarcia
Copy link

I have reported this issue before.

#3

@francescolavra
Copy link

Serial.println() returns the number of characters written to the serial port, so when you execute input = Serial.println(expander.read(), BIN) you are assigning to the input variable the number of characters written, which equals the size of the string "1111010" plus the "\r\n" sequence, i.e. 9 characters; that's why you see 1001.

@pierrot10
Copy link

@francescocolavra, Ok than could show use how we can display in a terminal or a LCD when the pin is HIGH?

@francescolavra
Copy link

Like that:
Serial.println(expander.digitalRead(myPin) ? "HIGH" : "LOW");

@pierrot10
Copy link

Dera Francesco, thank for your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants