Skip to content
Harpo edited this page Oct 2, 2019 · 1 revision

I2C

For performances and mission critical transmissions, I2C is more reliable than Serial and should be preferred.

Simplified example (from dmx/dmx.ino)

#define DMX_CHANNELS 5
// {PROGRAM, R, G, B, SPEED}

const byte I2C_ADDRESS = 42;
uint8_t DMX_PACKET[DMX_CHANNELS];

void sendPacket() {
  Wire.beginTransmission(I2C_ADDRESS);
  Wire.write(DMX_PACKET, DMX_CHANNELS);
  while (Wire.endTransmission()) {
  }
}

void loop() {
  readDMX();
  if (NEWS) {
    sendPacket();
  }
}
Clone this wiki locally