View Single Post
  #4   Spotlight this post!  
Unread 22-01-2017, 15:55
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 408
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
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);
    }
}
Arduino:
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);
  }
}
__________________
Creator of SmartDashboard.js, an extensible nodejs/webkit replacement for SmartDashboard


https://ligerbots.org
Reply With Quote