Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   I2C Help reading sparkfun line follower array (http://www.chiefdelphi.com/forums/showthread.php?t=153421)

Joe_Chase 10-01-2017 20:22

I2C Help reading sparkfun line follower array
 
We're trying to read the line follower array with no success. It returns no data when read. The hardware (LED's, wires) is definitely working

The Device: https://www.sparkfun.com/products/13582

Has anybody got this device working? Help is appreciated.

Code:

package org.firstinspires.ftc.robotcontroller.internal;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DigitalChannel;
import com.qualcomm.robotcore.hardware.I2cAddr;
import com.qualcomm.robotcore.hardware.I2cController;
import com.qualcomm.robotcore.hardware.I2cDevice;
import java.util.concurrent.locks.Lock;
import com.qualcomm.robotcore.hardware.DeviceInterfaceModule;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl;

/**
 * Created by greenteam on 1/7/17.
 */

@TeleOp(name = "LineSensor", group = "Sensor")

public class LineFollower extends OpMode {

    I2cDevice device;
    boolean ready;
    I2cAddr address;
    I2cDeviceSynchImpl sync;
    byte sensorData;

    @Override
    public void init(){
        device = hardwareMap.i2cDevice.get("LineFollower");
        address = I2cAddr.create7bit(0x3E);
        sync = new I2cDeviceSynchImpl(device, address, false);
        sync.engage();
    }

    @Override
    public void loop(){
        ready = device.isI2cPortReady();
        if(ready){
            byte sensorData = sync.read8(0x00);
        }
        DisplayData();
    }

    public void DisplayData() {
        telemetry.addData("Ready: ", ready ? "True" : "False");
        String s = String.format("%02X", sensorData);
        telemetry.addData("Data: ", s);
    }

}



All times are GMT -5. The time now is 12:58.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi