Hi
Im hoping someone can help me im using an arduino mega connected to an external EEPROM (24LC256, using I2C and the wire.h library) to turn on some RGB leds 16 of them. i can add the values to the EEPROM which isnt the issue, the issue i am facing is reading multiple address in a loop, code below
void sequence_1(){
uint8_t _byte;
int d = 0;
for (int i = 3; i < 51; i++) {
Wire.beginTransmission(eeprom);
Wire.write((int)(i >> 8)); // MSB
Wire.write((int)(i & 0xFF)); // LSB
Wire.endTransmission();
Wire.requestFrom(eeprom,1);
if (Wire.available()){
_byte = Wire.read();
}
if(_byte == 1){
tlc.setLED(d, 3095, 0, 0);
//Serial.println("RED");
}
//Green//
if(_byte == 2){
tlc.setLED(d, 0, 3095, 0);
//Serial.println("Green");
}
//Blue//
if(_byte == 3){
tlc.setLED(d, 0, 0, 3095);
// Serial.println("Blue");
}
d = d + 1;
}
tlc.write();
}
As You can see my increment reads one address at a time using the variable 'i', which works great however i want to be able to read the first 3 adresses 'i, i+1, i+2' during each instance of the loop then read the next 3 on the next loop. of course where i added d=d+1 i can add i = i + 2 which will achieve that, however i would i b able to read the 3 addresses at the same time.
below is a visual representation of what i want to achieve
i, r = 3
i + 1, g = 4 led 1
i + 2, b = 5
----------------------- i = i + 2
i, r = 6
i + 1, g = 7 led 2
i + 2, b = 8
----------------------- i = i + 2
.
.
.
.
.
I hope that helps and any help would be great
Thank you