Hey Everyone,
I hope someone can point me in the correct direction here, I am at a loss. I am trying to get my MCP23017 working. Before I start adding it to my design I just want to be sure it works. So far I can’t get it working. That goal is to have 4 LED outputs, 4 Relay outputs & 2 button inputs going through the MCP23017. For now I am just trying to get a loop created so the LED’s chase each other one second apart. I have reviewed my code over and over and looked up whatever samples I can find, I must be doing something wrong.
I appreciate your help! Also I am new to coding and IOT, this is also my first post here so if I do something wrong please educate me so I can learn.
#include <Adafruit_MCP23017.h>
Adafruit_MCP23017 mcp;
int led0 = 28;
int led1 = 27;
int led2 = 26;
int led3 = 25;
void setup() {
Serial.begin(9600);
mcp.begin();
mcp.pinMode(led0, OUTPUT);
mcp.pinMode(led1, OUTPUT);
mcp.pinMode(led2, OUTPUT);
mcp.pinMode(led3, OUTPUT);
pinMode(7, OUTPUT);
mcp.digitalWrite(led0, HIGH);
mcp.digitalWrite(led1, HIGH);
mcp.digitalWrite(led2, HIGH);
mcp.digitalWrite(led3, HIGH);
}
void loop() {
mcp.digitalWrite(led0, LOW);
mcp.digitalWrite(led1, HIGH);
mcp.digitalWrite(led2, HIGH);
mcp.digitalWrite(led3, HIGH);
digitalWrite(7, LOW);
delay(1000);
mcp.digitalWrite(led0, HIGH);
mcp.digitalWrite(led1, LOW);
mcp.digitalWrite(led2, HIGH);
mcp.digitalWrite(led3, HIGH);
digitalWrite(7, HIGH);
delay(1000);
mcp.digitalWrite(led0, HIGH);
mcp.digitalWrite(led1, HIGH);
mcp.digitalWrite(led2, LOW);
mcp.digitalWrite(led3, HIGH);
digitalWrite(7, LOW);
delay(1000);
mcp.digitalWrite(led0, HIGH);
mcp.digitalWrite(led1, HIGH);
mcp.digitalWrite(led2, HIGH);
mcp.digitalWrite(led3, LOW);
digitalWrite(7, HIGH);
delay(1000);
}
Here is my diagram of my end result, got a few more sensors Ill add directly to the photon later. I’m just trying to confirm my basic code works with the MCP23017 that I have, and so far it’s not.
Thanks a bunch!