Ultrasonic sensor won't work in NXC/Bricxcc
Ultrasonic sensor won't work in NXC/Bricxcc
I have not been able to get the ultrasonic sensor to work with Bricxcc, either when written into a program, or when reading the values directly using the "watching the brick" tool. When using the tool, the value always reads "0." I set the sensor to type "lowspeed" using the direct control tool. Any suggestions?
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Ultrasonic sensor won't work in NXC/Bricxcc
In the program, did you set it to LowSpeed? Did you make sure you used the right port number? Can you post a program that demonstrates the issue? What version of FW are you running on the NXT? What BCC version are you using?
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Ultrasonic sensor won't work in NXC/Bricxcc
To read an I2C device value via the Watching the Brick tool you need to use the I2C section on the NXT tab. You can't view its value using the regular analog sensor watch fields.
Lots of people have used this sensor in NXC. You need to read its value via SensorUS rather than Sensor, which only works for analog sensor values. The NXC help describes how to do this.
John Hansen
Lots of people have used this sensor in NXC. You need to read its value via SensorUS rather than Sensor, which only works for analog sensor values. The NXC help describes how to do this.
Code: Select all
task main()
{
SetSensorLowspeed(S1);
while(true)
{
NumOut(0, LCD_LINE1, SensorUS(S1), true);
Wait(SEC_1);
}
}
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Who is online
Users browsing this forum: No registered users and 1 guest