-
Notifications
You must be signed in to change notification settings - Fork 1
Changing the Arduino's I2C speed to 9600Hz
FROGbots-4634 edited this page Jun 9, 2019
·
1 revision
The HiTechnic controllers use an unusually slow I2C speed of 9600Hz. By default, the Arduino runs I2C at 100KHz, which results in corrupted communications with the controllers. This issue can be rectified by setting the Arduino's I2C speed to 9600Hz.
Unfortunately, I only have an Arduino Uno, so I can only guarantee that these instructions will work for that specific board.
- Close the Arduino IDE if you have it open
- Navigate to
arduinoInstallDir/hardware/arduino/avr/libraries/Wire/src/utility
- Open
twi.c
in a text editor of your choice - Find this line
// initialize twi prescaler and bit rate
- Change the line directly below from
cbi(TWSR, TWPS0);
tosbi(TWSR, TWPS0);
- Save and close the file.
- Make sure to put
#define TWI_FREQ 37390L
at the top of your sketch!