diff options
| author | Abel Tim <abel@main.home> | 2024-06-05 20:46:26 +0200 |
|---|---|---|
| committer | Abel Tim <abel@main.home> | 2024-06-05 20:46:26 +0200 |
| commit | fb9cb6c32e04434fd689aea99143d96aa2811656 (patch) | |
| tree | f343f8afa4ff3ff1f0fea73fc39efe1e20607618 /MCP23017/with_lib/with_lib.ino | |
| parent | 51051da4e85ae296bedb6d3709947e5311deee07 (diff) | |
| download | robotica-fb9cb6c32e04434fd689aea99143d96aa2811656.tar.gz robotica-fb9cb6c32e04434fd689aea99143d96aa2811656.zip | |
add mcp
Diffstat (limited to 'MCP23017/with_lib/with_lib.ino')
| -rw-r--r-- | MCP23017/with_lib/with_lib.ino | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/MCP23017/with_lib/with_lib.ino b/MCP23017/with_lib/with_lib.ino new file mode 100644 index 0000000..f99065a --- /dev/null +++ b/MCP23017/with_lib/with_lib.ino @@ -0,0 +1,28 @@ +/** Inputs.ino + * Sets port 7 on bank B to INPUT_PULLUP and copies its + * state to the built-in LED on the board + * https://github.com/ndomx/MCP23017-Arduino-Library + */ + +#include <mcp23017.h> + +#define MCP_ADDR (0) + +MCP23017 mcp(MCP_ADDR); + +void setup(void) +{ + Serial.begin(9600); + pinMode(LED_BUILTIN, OUTPUT); + + mcp.start(); + mcp.pinMode(GPB7, INPUT_PULLUP); +} + +void loop(void) +{ + byte mcp_input = mcp.digitalRead(GPB7); + digitalWrite(LED_BUILTIN, mcp_input); + Serial.println(mcp_input); + delay(500); +} |
