View Single Post
  #3   Spotlight this post!  
Unread 05-02-2017, 16:20
CSkillet CSkillet is offline
Registered User
FRC #0135
 
Join Date: Jan 2016
Location: Indiana
Posts: 12
CSkillet is an unknown quantity at this point
Re: Reading I2C MXP port on roborio

https://www.arduino.cc/en/Reference/Wire

The Arduino Wire Library for I2C Communications has two functions that are very familiar. They are onReceive() and onRequest.

The roboRIO always acts as the master for all I2C transactions, so the RoboRIO has to tell the Arduino to read AND write values. The onReceive(handler) function tells the Arduino to execute handler when the RoboRIO writes data to the Arduino. The onRequest(handler) functions tells the Arduino to execute handler when the RoboRIO is reading data from the Arduino.

My point is that you have to use onRequest(). Since the Arduino is setup as a slave device, it has to be told by the RoboRIO that it is okay to send data. Otherwise, data will not be sent. Overall, onRequest() is enabling to Arduino to Write values to the RoboRIO, and onReceive() is enabling the Arduino to read values.
Reply With Quote