Library | Building | Programming | Quick Guides Home | Quick Guides to Building | Quick Guides to Programming | LVLM | WeDo
LEGO MINDSTORMS NXT Software

DocumentsDate added

Order by : Name | Date | Hits | [ Descendent ]
file icon Line Follower: Wait for Darkhot!Tooltip 05/30/2006 Hits: 5338


This program runs Motor A until the light reading is less than 50. Once the light reading is less than 50, Motor A stops and Motor C runs for 0.25 seconds. This processed is infinitely looped. 

file icon Play the Scalehot!Tooltip 05/30/2006 Hits: 5598

View Program

The NXT can also be used to play music. By placing notes manually custom songs can be created.

file icon Lurch - 1hot!Tooltip 05/30/2006 Hits: 5666

 

This code uses a Loop to turn Motor A on-and-off three times. When downloaded to a single motor car, this program will accelerate the vehicle forward in three short bursts. The number of loops can be changed by modifying the Count of "3". Alternatively, if you want an infinite program, you can set the Control of the Loop to Forever.

file icon Line Follower: Switchhot!Tooltip 05/30/2006 Hits: 5816

 

This program is works like the Line Follower: Wait for Dark program but it uses a Switch. The program runs a Switch--in a infinite Loop--that runs Motor A and makes sounds when reading light. The program stops Motor A then runs Motor C for 0.25 seconds when reading dark.

file icon Snakehot!Tooltip 05/30/2006 Hits: 6423

View Program

When run, this code will cause a car to "snake" forward in wide arcs. The length of the turns can be modified by changing either the time or motor power.

file icon Wait for Pushhot!Tooltip 05/30/2006 Hits: 6465

 

This code illustrates the Wait-for-Push command. When a touch sensor on Port 1 is pressed, Motor A will stop.

file icon Wait For Randomhot!Tooltip 07/02/2007 Hits: 6979

 

This code creates a wait for loop that will wait for a random amount of time. The code uses the random number generator and a loop that waits for the timer to equal the generated value. The random number is set between 500 and 5000, which causes the loop to wait for 500 and 5000 milliseconds. Code by Brian Davis.

file icon Touch Sensor Switchhot!Tooltip 05/30/2006 Hits: 7037

 

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.

View Program


If a car is programmed to travel 12?, how do we know is actually traveled that distance? Often, the cars momentum will carry it past the desired location even though the motors have stopped running. The solution to this problem is a proportional control loop. By continually monitoring the distance from the desired location, the motor speed can be slowed as the car approaches. The governing formula is defined as P*(desired-current) where P is an arbitrary constant.

In this program, a desired location is set at 50 degrees of the rotation sensor. This value is continually subtracted by the current rotation traveled. The difference is multiplied by two and this becomes the value of the "power" variable. The Compare Block determines the direction Motor C will travel: forward if "power" is positive, backward if "power" is negative. Thus, when the car first starts off, its current position is zero and its desired position is 50. Therefore, the power setting used is 100, which is full power forward. If the car overshoots its mark, the power setting will become negative and the car will travel in reverse. The goal of proportional control is to find a constant that will get the system to equilibrium in the shortest time with the least amount overshoot and the most accuracy.

file icon Echo Locationhot!Tooltip 06/12/2006 Hits: 8440

View Program
 

In this code, sound frequencies are played corresponding to changing light values. Light sensor readings, which fall between 0-100, are placed in a variable and multiplied by the constant 8. The value of that variable, which now falls between 0-800, becomes the frequency in Hz of the sound played. The frequency is also displayed on the NXT.

«StartPrev123NextEnd»
Page 2 of 3
Home | About Us | Contact Us
© 2013 Center for Engineering Educational Outreach, Tufts University
© 2013 The LEGO Group. All rights reserved.