Skip to content

Instantly share code, notes, and snippets.

@HON95
Created March 7, 2017 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HON95/5a06355b4e9e20f9ec065ab1dd4351dc to your computer and use it in GitHub Desktop.
Save HON95/5a06355b4e9e20f9ec065ab1dd4351dc to your computer and use it in GitHub Desktop.
/*
Pinout:
Connect pin #1 of the expander to Analog 5 (i2c clock)
Connect pin #2 of the expander to Analog 4 (i2c data)
Connect pins #3, 4 and 5 of the expander to ground (address selection)
Connect pin #6 and 18 of the expander to 5V (power and reset disable)
Connect pin #9 of the expander to ground (common ground)
*/
#include <Wire.h>
#include <Adafruit_MCP23008.h> // From plab-libraries
#define PIN_EXPANDER_ADDRESS 0
#define EXPIN_LED 4
Adafruit_MCP23008 expander;
void setup() {
expander.begin(PIN_EXPANDER_ADDRESS);
expander.pinMode(EXPIN_LED, OUTPUT);
}
void loop() {
expander.digitalWrite(EXPIN_LED, LOW);
delay(500);
expander.digitalWrite(EXPIN_LED, HIGH);
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment