What's kOnBoard for i2c with arduino?

We have no idea what kOnBoard is.

For

	private static I2C Wire = new I2C(Port.kOnboard, 4);

We saw some people use 8, 2, or other numbers instead of the 4. What do we use?

We’re also not exactly sure where each thing from the i2c port on the Roborio should be connected on the Arduino. We saw that A4 goes to sda and A5 goes into scl but is this correct? What about the two other pins?

In the inner enums of all communication interfaces (SPI, I2C, Serial, USB) the kOnboard value is the connection on the roborio, and kMXP is the one on the expansion board (for example, navX).

So what number should we use

As we have never used I2C, I don’t know about ID or wiring. RTFM or read other threads that discuss I2C.

The number needs to match the I2C ID number you set in the arduino code. That’s how I2C knows which device to communicate with.

Oh okay. On the Arduino we wrote “Wire.begin(4);”

So kOnBoard should be 4?

kOnBoard and the number are 2 totally different things. kOnBoard is saying the device is hooked up to the Onboard I2C header, not the MXP header, and the number is saying which ID to use to access the device. So the 2nd parameter should be 4 if thats what you set your arduino board to.

Thank you. Could you still expand upon what you mean by setting the Arduino?

He’s referring to the 4 in your Wire.begin(4). If you instead had Wire.begin(2), then you would use new I2C(Port.kOnboard, 2) instead of new I2C(Port.kOnboard, 4)

1 Like

Ah okay. Thank you! This makes sense.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.