Go Down

Topic: [Solved] Reading data from a PCF8574 (Read 518 times) previous topic - next topic


Feb 07, 2013, 08:37 pm Last Edit: Feb 08, 2013, 02:34 pm by Mubanga Reason: 1

I'm fairly new to Arduino, I did a few basic projects. Now I'm trying to learn more about the PCF8574 I/O bus expander. I was able to connect 8 LED's and make them blink one at the time without to much trouble. But now I'm trying to read a button push and it's giving me a hard time for the past 2 days.

This is the way I've set up my project:

and this is the code I'm using:
Code: [Select]
#define  DEVICE_ADDRESS  56

#include <Wire.h>

byte x=0;

void setup()

void loop()
 x = Wire.read();


If somebody could take a look and tell me what I'm doing wrong, that would be great!

Nick Gammon

You don't do Wire.read on its own like that. Here, read this:


Nick Gammon

For one thing, you aren't even using this:

Code: [Select]

#define  DEVICE_ADDRESS  56

So how is it supposed to know which device?


You can look at your I2C read examples in the arduino IDE.

With this chip when you use it as an input you need to set the pins high with a write. Then the input will connect the pins to ground or not. You then read back the pins to see which have been shorted out.
This is the only chip I know that works like this, it is most unconventional.


I've got a much better understanding about I2C's now and got it working. Thank you both!

Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview