Go Down

Topic: I2C Set and read individual pins (Read 897 times) previous topic - next topic

Hey,

I have a MCP23017 io expander that runs through i2c. It has two banks and I am able to read an entire bank or set and entire bank using a bit combination but is it possible to set individual pins on the MCP23017. For example, if I wanted to just read the state or write to the state of the 3rd pin on bank B of the MCP23017, how would I go about doing that?

Thanks

PaulS

Quote
how would I go about doing that?

Read the bank. Read or change the bit of interest. Write the bank.

Use bitRead and bitSet/bitWrite to read and write the individual bits.

Hi Alterach,

There is a Adafruit library for the MCP23017 that allows to read, write pins individually.
You can find an example, including code for an Arduino Uno at the bottom of this post:
http://christophhartel.com/arduino-io-expander-with-mcp23017-and-74hc4051/

Christoph


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy