Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reteps/825ffb41fd18686eff31f33b71c038b2 to your computer and use it in GitHub Desktop.
Save reteps/825ffb41fd18686eff31f33b71c038b2 to your computer and use it in GitHub Desktop.
I2C Communication between roborio & arduino

Wiring

wire scl to analog in wire sda to analog in

void setup() {
  Wire.begin(4);
  Wire.onReceive(dataReceived);
}
void dataReceived(int howMany) { 
    while ( Wire.available() > 0 ){
      int n = Wire.read();
      Serial.printf('Received %d\n',n);
    }

robot

arduino = I2C{I2C.Port.kOnboard, 4};
byte b = (byte) 1;
arduino.transaction(b, b.length, null, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment