Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Switches

Example 1:

True, False Boolean

Example 2:

Simultaneous Processing

Example 3:
With Touch

Additional Code

and Videos

 

Example 1 

The robot says "Light" or "Dark" depending on whether or not its light sensor is receiving light. 

What doe the 3 mean?

Example 2

Simulatanous Processing

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.

Additional Code and Videos

 

Switch Block with Light Sensor Code: http://www.legoengineering.com/knowledgemanager/questions/168/What+is+the+NXT-G+switch+block+for%3F

Line Following Code with Instructions: http://nebomusic.net/NXT-G-BasicLineFollow.html

LIne Follower Video http://www.youtube.com/watch?v=CviRh0g1sZQ

Line Follower Pictures and Code:   http://drgraeme.net/DrGraeme-free-NXT-G-tutorials/Ch24/Ch24V1G/default.htm

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