I'm trying to use an Ultrasonic Sensor for NXT, unafortunally the only value that I receive is -1,
I initialize the sensor when connecting to NXT :
- Code: Select all
nxt.SetSensorMode(NXTBrick.Sensor.First, NXTBrick.SensorType.LightActive, NXTBrick.SensorMode.Raw);
nxt.SetSensorMode(NXTBrick.Sensor.Second, NXTBrick.SensorType.LightActive, NXTBrick.SensorMode.Raw);
nxt.SetSensorMode(NXTBrick.Sensor.Third, NXTBrick.SensorType.Lowspeed9V, NXTBrick.SensorMode.Raw);
Then in order to get the sensor values I click on a button that executes the following code:
- Code: Select all
private void button1_Click(object sender, EventArgs e)
{
//output vars
NXTBrick.SensorValues sensor1, sensor2;
int ultrasound;
nxt.GetSensorValue(NXTBrick.Sensor.First, out sensor1);
nxt.GetSensorValue(NXTBrick.Sensor.Second, out sensor2);
nxt.GetUltrasonicSensorsValue(NXTBrick.Sensor.Third, out ultrasound);
MessageBox.Show(sensor1.Raw.ToString() + " " + sensor2.Raw.ToString()+" "+ultrasound.ToString());
}
What I get Is something like 560 540 -1, as you see the last number is the ultrasonic sensor value,
Using NXT Test, it says that my NXT firmware is 1.3, protocol 1.2, lejos 0.9.1,and using Port 3 with sensortype lowspeed9v and raw mode ,throws:
row=scaled=calibrated=1023
normalized=0
does someone know if my error is in my code, or in the library? does I need to use lswrite, lsread to get the real values from sensor?