Thursday, January 10, 2008

NXT-G Program Basic Lesson 6- Random Block


Use of Random Block







Video Clip Demonstration


As you can see from the images above, the text to display will comefrom the output data plug on the number to TEXT block. The random number generated will stay on the LCD screen until one press the Left Button.

Wednesday, January 2, 2008

NXT-G Program Basic Lesson 5- Switch Block



Lesson on use of Switch Block
Today you decide you want to do different things depending on whether the touch sensor is pressed or not. The touch sensor is a button, and your NXT-G program can make decisions depending on which state it is in.

To do this, you would use a Switch Block. By default, it is set up to make a decision using the touch sensor, but it has many other uses.

When you add a Switch Block, a box shows up in your program with the "switch"part on the left. Inside the box are two sequence beams, instead of the usual one. The blocks (you have to add them, of course) on the top beams are only run if the switch condition is "true". The bottom is run for "false".

The condition is indicated by the choices in the panel at bottom-left. Check that the Port is the one you have wired the sensor to, and change it if necessary. Everything else should be already set correctly for this use.

In the example, you are running a car with motors connected to ports B and C. If the touch sensor is pressed when it gets to this part of the program, it will run forward for 2 seconds. If not, it will go backwards for 2 seconds. If this was the complete program, you would have to press the button as the program is started to have the car go forward.




Use of Switch Block

The switch block allows one to make choices



The flat view of the swtich block



Tabbed view of the switch block



Five different paths for the switch block





Switch block with two possible paths



Second switch using sound sensor



NXT robot will turn right if the first and second switch block conditions are met





Tuesday, January 1, 2008

NXT-G Program Basic Lesson 4- Loop Block



Lesson on Loop Block
A set of instructions to do over and over and over until
something else happens. It may be that touch sensor
is pressed or the sound sensor detects a noise or the time reaches
infinity.
When dropping a block inside a LOOP block, continue to
hold down the mouse button and move the new block
inside the Loop block until the loop block explains.
A Simple MOVE Block inside a Loop Block



The Control Section of the Loop Block



The Control Section of the Loop Block configured for Time



Loop Block set to forever



A Loop Block configured to break using a touch sensor



Nested Loop
This means a loop inside a loop. When the program runs,
any blocks inside the outer loop block will run. First, the inner loop will run three times
(executing MOVE and SOUND blocks inside it) and then break. Then the Light sensor will send
a True/False Logic response to the outer loop block's data plug. If the Light sensor does not
detect a light level greater than 90, the outer Loop block will not break and will run whatever
is inside it again.



There is a data wire connecting the Light sensor to the outer loop block. In the control section of the outer loop block, the Logic option is selected and wait until it receives a True response from the Light sensor block.
If the Light sensor block does not detect a light level greater than 90, the Yes/No data plug sends a False signal to the outer loop block causing the outer loop block to loop again.

Monday, December 31, 2007

NXT-G Program Basic- Lesson 3- Wait Block



Lesson 3 Wait Block
The Wait Block will stop when specific conditions are met.
NXT robot will keep moving forward until a special condition is met.
And with NXT-G that condition can occur using a sensor, timer, an NXT button,or a time limit. Consider a NXT-G program to spin motors A and C forward with an unlimited duration and a power setting of 50



Time Wait Block



Light Sensor Wait Block



The Nxt Button Wait Block



The Rotation Sensor Wait Block



The Sound Sensor Wait Block



The Timer Wait Block



The Touch Sensor Wait Block



The Ultrasonic Sensor Wait Block




Thursday, December 27, 2007

NXT-G Program Basic-Lesson 2 Sensors




NXT-G Program Basic- Sensors









































NXT-G Configuring the Sensors
Sensors include NXT Touch, NXT Sound, NXT Light, NXT Ultrasonic,
NXT Rotation.
Sensors detect a change in a condition. The condition could be a change in light level,a change in volume(sound) or maybe a change in position (movement).
The sensor is simply watching the changes in its condition.
Sensor Programming Blocks can only respond to one condition at a time. When one drop
a sensor block into an NXT-G program, it has to be configured to test one condition.
A single Light sensor, for example, cannot be configured to test whether the light in a room is below 80 and greater than 50. In order to test both conditions, one would need to use two Light sensor blocks in one's program.
Finally, sensors can provide only a Logic type response:True or False.



Data Block



Typical Touch Sensor Data connected with a wire



NXT Touch Sensor's configuration panel




NXT-G Program Basic-Lesson 1



NXT-G Program Basic-1