Switches
|
Example 3: With Touch |
The robot says "Light" or "Dark" depending on whether or not its light sensor is receiving light.
What doe the 3 mean?

NXT can be programmed to handle 2 or more events at the same time. The sequence beam shown below divides into 2 and both branches run simultaneously.
The upper beam alternately displays 2 images for 1 second each (displaying images is simple but not covered in the course)
At the same time, the lower brance generates a bleeping sound of 2 second tone bursts every 2.4 seconds. The NXT's microcontroller runs the 2 activities simultaneously.

Example 3: Used with Touch Sensor

SWITCH and TOUCH: This code uses two very important coding commands, Switches and Loops. The touch sensor Switch causes Motor A to go forward if the touch sensor is released and backward if it is pressed. The Loop causes the Switch to loop infinitely.
Switch Block
with Light Sensor Code
Line Following
Code with Instructions
LIne Follower
Video
Line Follower
Pictures and Code
Line follower video: http://www.youtube.com/watch?v=FtmINVZ26sQ
Switches: http://www.wonderhowto.com/how-to-program-switches-lego-mindstorms-nxt-system-79061/view/
Calibrating the light sensor and use with switches: http://drgraeme.net/DrGraeme-free-NXT-G-tutorials/Ch24/Ch24V1G/05%20MindStorms/05ChPhoto.htm
Line following code and video: http://drgraeme.net/DrGraeme-free-NXT-G-tutorials/Ch24/Ch24V1G/03%20MindStorms/03ChPhoto.htm