|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: Arduino & Roborio cant find each other I2C Issues
We've done exactly that, but for some reason onRequest was not being triggered... Any ideas how to troubleshoot this?
|
|
#2
|
||||
|
||||
|
Re: Arduino & Roborio cant find each other I2C Issues
Could you post the code you're using (roborio and arduino)?
|
|
#3
|
|||
|
|||
|
Re: Arduino & Roborio cant find each other I2C Issues
Roborio code: http://pastebin.com/TiFcYq6L
Arduino: http://pastebin.com/TDPk9W5i Do keep in mind we did try using onREquest for arduino and set it up as a slave prior but for some reason it didnt work. My team is confused, even the mentor is having trouble explaining what's happening. |
|
#4
|
||||
|
||||
|
Re: Arduino & Roborio cant find each other I2C Issues
I see. Try this
roboRIO: Code:
static I2C arduino = new I2C(Port.kOnboard, 42);
@Override
public void teleopPeriodic() {
byte[] sendData = "sample text".getBytes();
byte[] receiveData = new byte[sendData.length];
boolean failed = arduino.transaction(sendData, sendData.length, receiveData, receiveData.length);
if(!failed) {
System.out.println("Got data: " + new String(receiveData, 0, receiveData.length);
}
}
Code:
#include <Wire.h>
void setup() {
Wire.begin(42);
Wire.onRequest(requestEvent);
Serial.begin(9600);
}
void loop() {
delay(100);
}
// send back the same data as we receive
void requestEvent() {
Serial.println("Got request:");
while (Wire.available()) {
char c = Wire.read();
Serial.print(c);
Wire.write(c);
}
}
|
|
#5
|
|||
|
|||
|
Re: Arduino & Roborio cant find each other I2C Issues
The Arduino didn't read anything from the roborio using this code. We've since switched to using a raspberry pi
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|