Coding Sensors Guide (LabVIEW™ for LEGO® MINDSTORMS ...

28 downloads 4216 Views 1MB Size Report
318. All sensors (except the built-in rotation sensor in the motor) connect to Ports 1, 2, 3, or 4. These ports are located on the bottom of the NXT brick and pass ...
TETRIX® Getting Started Guide

Additional Guides

Coding Sensors Guide (LabVIEW™ for LEGO® MINDSTORMS®) All sensors (except the built-in rotation sensor in the motor) connect to Ports 1, 2, 3, or 4. These ports are located on the bottom of the NXT brick and pass information through the NXT connector wires. Ensure that the wires connecting each sensor to the NXT brick are plugged into the correct port and that this has been correctly set up in the Schematic Editor. 1. Open the Schematic Editor in the Robot Project Center.

2. Choose the Sensor Port and the type of sensor that has been plugged into that port.

3. Name the sensor appropriately in the Name section.

318

Additional Guides

TETRIX® Getting Started Guide

Coding Sensors Guide (LabVIEW™ for LEGO® MINDSTORMS®) 4. Set the mode of the sensor in the Sensor Parameters section.

Touch Sensor: • Released: Boolean value of False when the sensor is pressed and True when it is released • Pressed: Boolean value of True when the sensor is pressed and False when it is released • Bumped: Boolean value of True when the sensor is released after being pressed and False otherwise

Light Sensor: • Light On: Measures the value of the reflected light from 0 to 100 • Light Off: Measures the value of the ambient light from 0 to 100

Sound Sensor: • dB: Measures the intensity of the sound in true decibels • dBA: Measures the intensity of the sound in decibels as a human ear would interpret it Ultrasonic Sensor: • Inches: Measures the distance of an object in inches • Centimeters: Measures the distance of an object in centimeters Note: The touch sensor will provide a digital signal, while the others will provide an analog signal. This means that the touch sensor will only be able to send two different pieces of information to the NXT brick (True or False, or in this case, pressed or not pressed), while the other sensors will send a numeric value. This is important to keep in mind when creating programs that use information from the sensors on the NXT Brick.

319

TETRIX® Getting Started Guide

Additional Guides

Coding Sensors Guide (LabVIEW™ for LEGO® MINDSTORMS®) 5. Check the status of the sensor in the Status section to make sure it is connected properly. Example 1: Touch Sensor The following program uses data from the touch sensor. The program will drive forward until the touch sensor is pressed. Once the touch sensor is pressed, the robot will stop and the program will end.

The code inside of the While Loop runs until the Touch sensor outputs a True value. Once the touch sensor is pressed, the code outside of the While Loop will run; the motors will stop and the program will end. Example 2: Ultrasonic Sensor The following program uses data from the ultrasonic sensor. The program will drive forward until the value from the ultrasonic sensor reads 50 or less, and then it will stop the motors and the program will end.

320

Suggest Documents