#include <Wire.h>
#include "Adafruit_MCP23017.h"
Adafruit_MCP23017 mcp;
int pattern[]={0b0000000000000000,
0b1000000000000001,
0b1100000000000011,
0b1110000000000111,
0b0111000000001110,
0b0011100000011100,
0b0001110000111000,
0b0000111001110000,
0b0000011111100000,
0b0000001111000000,
0b0000000110000000,};
void setup() {
mcp.begin(); // use default address 0
for(byte i=0;i<=16;i++)
{
mcp.pinMode(i,OUTPUT);
mcp.digitalWrite(i,LOW);
}
}
void loop()
{
for(byte i=0;i<=10;i++)
{
send2port(pattern[i]);
delay(250);
}
}
void send2port(int data)
{
if (data & 1 ){mcp.digitalWrite(0,HIGH);} else {mcp.digitalWrite(0,LOW);}
if (data & 2 ){mcp.digitalWrite(1,HIGH);} else {mcp.digitalWrite(1,LOW);}
if (data & 4 ){mcp.digitalWrite(2,HIGH);} else {mcp.digitalWrite(2,LOW);}
if (data & 8 ){mcp.digitalWrite(3,HIGH);} else {mcp.digitalWrite(3,LOW);}
if (data & 16 ){mcp.digitalWrite(4,HIGH);} else {mcp.digitalWrite(4,LOW);}
if (data & 32 ){mcp.digitalWrite(5,HIGH);} else {mcp.digitalWrite(5,LOW);}
if (data & 64 ){mcp.digitalWrite(6,HIGH);} else {mcp.digitalWrite(6,LOW);}
if (data & 128 ){mcp.digitalWrite(7,HIGH);} else {mcp.digitalWrite(7,LOW);}
if (data & 256 ){mcp.digitalWrite(8,HIGH);} else {mcp.digitalWrite(8,LOW);}
if (data & 512 ){mcp.digitalWrite(9,HIGH);} else {mcp.digitalWrite(9,LOW);}
if (data & 1024 ){mcp.digitalWrite(10,HIGH);} else {mcp.digitalWrite(10,LOW);}
if (data & 2048 ){mcp.digitalWrite(11,HIGH);} else {mcp.digitalWrite(11,LOW);}
if (data & 4096 ){mcp.digitalWrite(12,HIGH);} else {mcp.digitalWrite(12,LOW);}
if (data & 8192 ){mcp.digitalWrite(13,HIGH);} else {mcp.digitalWrite(13,LOW);}
if (data & 16384 ){mcp.digitalWrite(14,HIGH);} else {mcp.digitalWrite(14,LOW);}
if (data & 32768 ){mcp.digitalWrite(15,HIGH);} else {mcp.digitalWrite(15,LOW);}
}