Have you been successful Chris or somebody else with this issue?
I'm desperating. I tried all nearly all combinations but it doesn't work.
I use LeJos 0.8 and want to use 2 sensors with the mindensors port splitter: a light sensor and the hitechnic compass sensor. That must theoretically work together. The first is an analog sensor, the second a digital one.
According to lawrie, something like :
- Code: Select all
byte[] newAddress = {(byte) 0xA0, (byte) 0xAA, (byte) 0xA5, (byte) 0x04};
I2CSensor s1 = new I2CSensor(SensorPort.S1);
s1.sendData(0x41, newAddress, 4);
LightSensor lightSensor = new LightSensor(SensorPort.S1);
CompassSensor compassSensor = new CompassSensor(SensorPort.S1);
compassSensor.setAddress(0x02);
// ------------------------------------------------------------------------
// read out values
while (!Button.ESCAPE.isPressed())
{
int x = 0;
int y = 0;
LCD.drawString(LABEL_COMPASS, x, y);
x+=LABEL_COMPASS.length();
LCD.drawInt((int)compassSensor.getDegreesCartesian(), 3, x , y);
x+=3;
LCD.drawString(" Grad", x, y);
x = 0;
y++;
LCD.drawString(LABEL_LIGHT, x, y);
x+=LABEL_LIGHT.length();
LCD.drawInt(lightSensor.readValue(), 3, x , y);
x+=3;
LCD.drawString("cm", x, y);
LCD.refresh();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
}
}
must work. But it doesn't.
I suspect it writes on the wrong registers maybe. Could it be there is a hidden extra register where the i2c address is saved. If so, which one is it? There is no information about the I2C address register of the hitechnic compass sensor on the hitechnic website.
I don't know what to do. (By the way searching on google gives no further help - of course I tried it)
Has anybody advice or ideas ?
Michael