Hi,
I have two Arduino boards connected by I2C. I connected some switches to the master board and some LED’s to the slave board. The LED just have to follow it’s switch (on/off). When I start using arrays everything goes wrong. It seems I can’t get the array into the I2C. Can someone show me the right direction? I’m comfortable with arrays and had some successful tests with I2C.
This is all i have...
Master:
#include <Wire.h>
int SwitchArray[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
void setup()
{
Wire.begin();
int i;
for (i=0;i<15;i++){
pinMode(SwitchArray[i], INPUT);
}
}
slave:
#include <Wire.h>
int LEDArray[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
void setup()
{
Wire.begin(9);
Wire.onReceive(receiveEvent);
int i;
for (i=0;i<15;i++){
pinMode(LEDArray[i], OUTPUT);
digitalWrite(LEDArray[i], LOW);
}
There’s probably a lot of code missing, but that’s why I ‘m consulting the forum.
Basically this is what I’m trying to achieve. I have allot of switches (more than 15 in the example) on one arduino board (Mega 2560) and as many LED’s on another board (also Mega 2560).
I wanted to setup an array to read in the switches, put that on i2c to send it to the other board and write that to the LED’s by using another array in the second board.
I don’t think it’s that difficult, but somehow I just can’t find the right code combination… :~