Pages: [1]   Go Down
Author Topic: I2C Set and read individual pins  (Read 681 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Kalamazoo Michigan
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Pages: [1]   Go Up
Jump to: