Skip to content

Commit 043bc52

Browse files
committed
Create README.md
1 parent 68c1ad5 commit 043bc52

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# MCP23017-Arduino-Library
2+
3+
![release badge](https://img.shields.io/github/v/release/ndomx/MCP23017-Arduino-Library?style=flat-square)
4+
![license badge](https://img.shields.io/github/license/ndomx/MCP23017-Arduino-Library?style=flat-square)
5+
6+
7+
This is a library to control MCP23017 I2C modules (product page [here](https://www.microchip.com/en-us/product/mcp23017)). The library provides full control of the module using familiar functions like `digitalWrite`, `digitalRead` and `pinMode`, as well as other functionalities.
8+
9+
> Note: The library does not support interrupts yet
10+
11+
## Usage
12+
Begin by including the library files and declaring an instance of the `MCP23017` class.
13+
~~~c++
14+
#include <mcp23017.h>
15+
16+
#define MCP23017_ADDR (0x07) // I2C address of the module
17+
MCP23017 mcp(MCP23017_ADDR);
18+
~~~
19+
20+
Every instance of the `MCP23017` class must be initialized after created. This will setup the module so it's compatible with the library, and initializes the `Wire` library if needed. To do this, just call the `start()` function inside `setup()` or `loop()`
21+
22+
After the instance is initialized, Arduino functions can be used to configure the additional I/O ports. These ports will be labeled `GPAn` for ports in the _A_ bank, and `GPBn` for ports in the _B_ bank (`0 <= n < 8`). Below you'll find a basic example, and there are more examples in the [examples folder](https://github.com/ndomx/MCP23017-Arduino-Library/tree/master/examples).
23+
~~~c++
24+
// Blink a LED
25+
26+
#include <mcp23017.h>
27+
28+
#define MCP_ADDR (0)
29+
30+
MCP23017 mcp(MCP_ADDR);
31+
32+
void setup(void)
33+
{
34+
mcp.start();
35+
mcp.pinMode(GPB7, OUTPUT);
36+
}
37+
38+
void loop(void)
39+
{
40+
mcp.digitalWrite(GPB7, HIGH);
41+
delay(250);
42+
mcp.digitalWrite(GPB7, LOW);
43+
delay(250);
44+
}
45+
~~~

0 commit comments

Comments
 (0)