How to use Pixycam with Arduino?

Hello friends. I am Baris. My team is 8182 Loth. Rookie year 2020. I write labview before. I am writing java. I have a question. How to communication roborio and arduino ? I communicated but i can’t convert string to int . How to communication i2c protocol ?
I don’t find i2c pixy example. Please help me ! Sorry bad english. :slight_smile:

public class Robot extends TimedRobot {
Talon sol;
Talon sag;
private SerialPort arduino;
private Timer timer;
private String x;
private String y;
private String w;
private String h;
String deger_x;
int deger_y ;
int deger_w ;
int deger_h ;
public void robotInit() {
sol = new Talon(0);
sag = new Talon(1);
try {
arduino = new SerialPort(9600, SerialPort.Port.kUSB);
System.out.print(“Connected on kUSB1”);
} catch (final Exception e) {
System.out.println(“Failed Connect”);
try {
arduino = new SerialPort(9600, SerialPort.Port.kUSB1);
System.out.print(“Connected on kUSB1”);
} catch (final Exception e1) {
System.out.println(“Failed Connect”);
try {
arduino = new SerialPort(9600, SerialPort.Port.kUSB2);
System.out.print(“Connected on kUSB1”);
} catch (final Exception e2) {
System.out.println(“Failed Connect”);
}
}
}
timer = new Timer();
//timer2 = new Timer();
timer.start();
//timer2.start();
}

@Override
public void robotPeriodic() {

if (timer.get() > 0.5) {
  arduino.write(new byte[] { 0x12 }, 1);
  x = arduino.readString();
  System.out.printf("X DEGERI:  "+x);
  System.out.println("");
 timer.reset();

  arduino.write(new byte[] { 0x10 }, 1);
  y = arduino.readString();
  System.out.printf("Y DEGERI:  "+y);
  System.out.println("");
  timer.reset();

  arduino.write(new byte[] { 0x11 }, 1);
  w = arduino.readString();
  System.out.printf("W DEGERI:  "+w);
  System.out.println("");

 arduino.write(new byte[] { 0x16 }, 1);
 h = arduino.readString();
 System.out.printf("H DEGERI:  "+h);
 System.out.println(""); 

timer.reset();
}