Library | Building | Programming | Quick Guides Home | Quick Guides to Building | Quick Guides to Programming | LVLM | WeDo
ROBOLAB

DocumentsDate added

Order by : Name | Date | Hits | [ Ascendant ]
file icon NXT - Multiple Eventshot!Tooltip 06/11/2006 Hits: 6948

 

Just like single events, multiple events can be setup in the same code to track different variables. The only difference is that all event structures must have the same event landing. This means that if 3 events are setup and only one triggers, the code will have to determine which one of the 3 changed so it can perform the appropriate action. In this example, two push events are used to control the motion of a car. After setting up both events, monitoring is started and the code is forced into an infinite loop. This is done to prevent the code from reaching the event landing block prematurely. If the red event (touch sensor 1) is triggered, the code will take the upper path in the event fork and stop motor A. If the red event was not triggered, then by default, the blue event must have been triggered and the code will take the bottom the path of the fork. Three or more events can be checked by increasing the number of event forks.

file icon Wait for Pushhot!Tooltip 05/26/2006 Hits: 4891
file icon Touch Sensor Forkhot!Tooltip 05/26/2006 Hits: 3744
file icon 2 Button Touch Sensor Remotehot!Tooltip 05/26/2006 Hits: 3149

   The two-button remote control is a very versatile program for controlling Lego robots. It uses a series of touch sensor forks to determine which behavior you want to trigger. Since the forks are between a set of jumps, the program loops infinitely, and the behavior of the robot will change every time a different touch sensor is hit.

 

   In this program, the two-button remote is setup to control a car with motors on ports A and C. When only touch sensor 1 is pressed, motor A spins forward and motor A spins backward. This will turn the car left or right. When only touch sensor 2 is pressed, the motors are reversed and the car will spin the opposite direction. If both touch sensors are held, the car moves forward. When no touch sensors are held, the car does not move. Remember, each branch of the fork can control something different. It does not only work for a car. The touch sensors can trigger music, events, even mail to other robots. The possibilities are endless. 

file icon Line Follower: Eventshot!Tooltip 05/26/2006 Hits: 3009
file icon Show LASMhot!Tooltip 05/26/2006 Hits: 2863
file icon Sending and Recieving Mailhot!Tooltip 05/26/2006 Hits: 2764

Two RCX's can be programmed to communicate with each other using the mail function. Mail represents the passing of integer values between separate RCX's using the IR port. In this example, the same code is used for both the receiver and the sender, so that you may interchange the roles of two RCX's without having to re-program them.

The top half of the first split is the receiving algorithm. Each RCX will wait to receive mail from the other. Once this happens, the integer value received will be placed into the red container. The value is then displayed and the RCX beeps a corresponding number of times. The RCX then waits for mail again.

The bottom half of the first split is the sending algorithm. The user can enter in a mail value to send by pressing touch sensor 1 the desired number of times. For example, if number 3 was to be sent, touch sensor 1 would be pressed 3 times. Once this value is programmed, pressing touch sensor 2 will send the mail out. In general, mail is a useful way for RCX's to pass information to one another. It can be used to trigger responses, send positions, or pass container values.

 

file icon Proportional Controlhot!Tooltip 05/26/2006 Hits: 2650
file icon Reprogramming another RCXhot!Tooltip 05/26/2006 Hits: 2620
«StartPrev1234NextEnd»
Page 1 of 4
Home | About Us | Contact Us
© 2013 Center for Engineering Educational Outreach, Tufts University
© 2013 The LEGO Group. All rights reserved.