View Single Post
  #4   Spotlight this post!  
Unread 05-02-2017, 22:25
axton900's Avatar
axton900 axton900 is offline
Programming Co-Captain
FRC #1403 (Cougar Robotics)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2015
Location: New Jersey USA
Posts: 52
axton900 has a spectacular aura aboutaxton900 has a spectacular aura aboutaxton900 has a spectacular aura about
Re: Reading I2C MXP port on roborio

Quote:
Originally Posted by CSkillet View Post
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.
I believe that this is the correct solution for this issue
__________________
Team 1403: Cougar Robotics (2015 - present)

Reply With Quote