Having trouble using array's with centipede shield.
Is there a max length, for array in arduino.
Using port 0 (chip1), all input (16), in an array. compiler accepts it as valid,
but nothing works.
const int buttonPin[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; // pushbutton and limit switch pins
int buttonState = 0;// variable for reading the pushbutton status
Wire.begin(); // start I2C
CS.initialize(); // set all registers to default
CS.portMode(0, 0b1111111111111111); // set all pins on chip 1 to input
CS.portMode(1, 0b1111111111111111); // set all pins on chip 0 to output
CS.portMode(2, 0b0000000000000000);
CS.portMode(3, 0b0000000000000000);
CS.pinMode(Relay1, OUTPUT);
CS.pinMode(Relay2, OUTPUT);
CS.pinMode(Relay3, OUTPUT);
CS.pinMode(Relay4, OUTPUT);
CS.pinMode(sensor1, INPUT);
CS.pinMode(sensor2, INPUT);
CS.pinMode(sensor3, INPUT);
CS.pinMode(sensor4, INPUT);
/*..Initialize the pushbutton pins as an input..*/
int x;
for(int x = 0; x < 15; x++)
{
CS.pinMode(buttonPin[x], INPUT);
}
int x;
for(int x = 0; x < 15; x++)
{
buttonState = CS.digitalRead(buttonPin[x]);
}
if (buttonState == HIGH && buttonPin[x] == 4)//Up Button press
{
CS.digitalWrite(Relay2, RELAY_ON); //Activate Main Pump UP
}
//Sensor...
if (CS.digitalRead(sensor1) == HIGH && CS.digitalRead(sensor2) == HIGH)
{
CS.digitalWrite(Relay1, RELAY_ON);
}
else
{
CS.digitalWrite(Relay1, RELAY_OFF);
}
can't figure it out.
codes to large to post all.
Sensors work perfect with relays, buttons-nothing
Thanks