Witam wszystki mam stary sketch który działa tylko na sarych wersjach arduino.Chciałbym żeby działał na: Platformio niestety jak go wgrywam wyskakują błedy.
#include <Wire.h>
#include "Adafruit_MCP23017.h"
//Adafruit_MCP23017 *mcp[8];
Adafruit_MCP23017 mcp;
Adafruit_MCP23017 mcp2;
Adafruit_MCP23017 mcp3;
Adafruit_MCP23017 mcp4;
Adafruit_MCP23017 mcp5;
Adafruit_MCP23017 mcp6;
Adafruit_MCP23017 mcp7;
Adafruit_MCP23017 mcp8;
unsigned long previousMillis = 0; // will store last time was updated
const long intervalMilis = 500; // interval at which to blink (milliseconds)
byte pressTable[128][1];
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial);
Serial.println("\nI2C Scanner");
i2cscanner();
mcp.begin(0);
mcp2.begin(1);
mcp3.begin(2);
mcp4.begin(3);
mcp5.begin(4);
mcp6.begin(5);
mcp7.begin(6);
mcp8.begin(7);
byte i=0;
for(i=0;i<=15;i++){
mcp.pinMode(i, INPUT);
mcp.pullUp(i, HIGH);
}
for(i=0;i<=15;i++){
mcp2.pinMode(i, INPUT);
mcp2.pullUp(i, HIGH);
}
for(i=0;i<=15;i++){
mcp3.pinMode(i, INPUT);
mcp3.pullUp(i, HIGH);
}
for(i=0;i<=15;i++){
mcp4.pinMode(i, INPUT);
mcp4.pullUp(i, HIGH);
}
for(i=0;i<=15;i++){
mcp5.pinMode(i, INPUT);
mcp5.pullUp(i, HIGH);
}
for(i=0;i<=15;i++){
mcp6.pinMode(i, INPUT);
mcp6.pullUp(i, HIGH);
}
for(i=0;i<=15;i++){
mcp7.pinMode(i, INPUT);
mcp7.pullUp(i, HIGH);
}
for(i=0;i<=15;i++){
mcp8.pinMode(i, INPUT);
mcp8.pullUp(i, HIGH);
}
delay(1000);
}
void loop() {
byte in;
byte i;
for(i=0;i<16;i++){
in = mcp.digitalRead(i);
if(in == 0){
pressTable[i][0] = 1;
}
}
for(i=0;i<16;i++){
in = mcp2.digitalRead(i);
if(in == 0){
pressTable[i+16][0] = 1;
}
}
for(i=0;i<16;i++){
in = mcp3.digitalRead(i);
if(in == 0){
pressTable[i+32][0] = 1;
}
}
for(i=0;i<16;i++){
in = mcp4.digitalRead(i);
if(in == 0){
pressTable[i+48][0] = 1;
}
}
for(i=0;i<16;i++){
in = mcp5.digitalRead(i);
if(in == 0){
pressTable[i+64][0] = 1;
}
}
for(i=0;i<16;i++){
in = mcp6.digitalRead(i);
if(in == 0){
pressTable[i+80][0] = 1;
}
}
for(i=0;i<16;i++){
in = mcp7.digitalRead(i);
if(in == 0){
pressTable[i+96][0] = 1;
}
}
for(i=0;i<16;i++){
in = mcp8.digitalRead(i);
if(in == 0){
pressTable[i+112][0] = 1;
}
}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= intervalMilis) {
for(i=0;i<129;i++){
if(pressTable[i][0] == 1){
Serial.print("Press MCP: ");
Serial.println(i);
}
}
resetTable();
previousMillis = currentMillis;
}
}
void resetTable(){
byte i;
for(i=0;i<129;i++){
pressTable[i][0] = 0;
}
}
void i2cscanner() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
nDevices++;
}
else if (error==4)
{
Serial.print("Unknown error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
}