There are no blocks hidden in the false condition tabs of the switches because in this part of the program no action is taken when one of the Touch Sensors is not pressed. The two switches are placed inside a Loop block so that the robot continuously checks to see whether both sensors are pressed. Because the robot needs to perform this check constantly, you place the blocks that control the Firing Motor on a Parallel Sequence Beam.
Figure Step 5: Place and configure a Loop block and two Switch blocks as shown, and then connect the blocks to the main program by connecting the Sequence Beams, as you did in step 4.
Figure Step 6: Place and configure three Motor blocks as shown. These blocks are run when the condition of both Switch blocks is true; in other words, when both Touch Sensors are pressed. The Turn and Turret motors are turned off, and the Firing motor starts to fire balls. Congratulations, you finished creating the remote-control program! Download the program to the Shot-Roller, and have fun! This is, of course, a lot of fun, but it is even more fun to create your own robot designs.
For example, you could take the shooter from this robot and mount it on your self-built car or tank, or you could turn it into a dangerous creature, such as a ball-shooting insect. Difficulty: Medium How far can the Shot-Roller shoot? The distance that a ball travels will depend on the angle that the Turret motor makes with the ground.
Which angle makes the ball go the farthest? Can you make it go even farther by modifying the shooter? Investigate the effect that the turret angle and the motor speed have on the distance of the fired ball. Can you modify the Shot-Roller design to mount the Ultrasonic Sensor on the turret, just below the ball magazine? This way, not only can you shoot in any direction, but you can also look in any direction so that the Shot-Roller has a better view of its targets.
Can you make a construction like a catapult that fires LEGO pieces when it sees you? You might use rubber bands to launch something or a plastic spoon that you bend with your hands. When using rubber bands, use ones other than those found in the NXT 2.
Figure Strider The Strider robot uses three identical motor assemblies to walk, each of which controls one pair of legs. The leg modules are interconnected with a triangle-shaped frame, which also carries the NXT with several sensors attached. The Ultrasonic Sensor allows the walker to measure the distance of nearby objects, while the Color Sensor in Light Sensor mode can detect whether it is dark or light outside. Table and Figure will show you how to connect the sensors. Figure shows how three minifigures can move a heavy object forward.
Figure Two minifigures pull the heavy object dashed arrows , and one pushes white arrow. As a result, the object moves forward solid black arrow. As a motor rotates, its attached leg pair walks by repeatedly putting one leg in front of the other. Whether a leg pair pushes or pulls the robot in a certain direction depends on whether the motor is configured to turn forward or backward Figure The combination of motor directions makes up the direction that Strider eventually walks in.
Figure Motors A and C pull the robot forward dashed arrows , and motor B pushes gray arrow. As a result, the Strider walks forward solid black arrow. The sensors have been removed here to make the motors more visible. Figure When NXT motors are specified to turn forward, the corresponding leg pair moves in the black direction. The gray denotes backward movement of the motor. NOTE The Strider can only walk on a really smooth surface, such as tiles, a desk, or a smooth wooden floor.
If you put it on carpet or a rough floor, the legs will probably break! Because motors A and C will pull the robot, those motors will rotate backward. Motor B will be configured to turn forward since its leg compartment pushes the robot. The Duration settings are all set to Unlimited so that the My Block will just switch on the motors. To begin, create a new program, pick three motor blocks from the Programming Palette, and configure them as shown in Figure Run the program, and the Strider should walk forward for 10 seconds and then stop when the program ends.
The blocks are essentially the same as the one you just made, except that the Direction and Power settings now make the robot move in a different direction, as shown in Figure Create these two My Blocks just like the one you made in the previous section, and see Table for their names and motor Direction and Power settings.
Figure The configuration of the blocks in the Walk-Forward My Block Figure A quick test program to make the Strider walk forward Figure By changing the direction in which its motors turn, the Strider can walk forward, left, or right. In each case, two motors pull the robot in one direction dashed arrows , and the third motor pushes the robot gray arrow.
The resulting direction is indicated with a solid black arrow. Difficulty: Easy You know how to drive in a triangle pattern using the Explorer robot, but how do you do it with the Strider robot?
For more fun, put all of these blocks in a Loop Block and add some Color Lamp effects or sounds. As you noticed in Discovery 43, the Strider cannot turn around, which means it will always look in the same direction with the Ultrasonic Sensor. Figure The program flow for the Strider-Touch program.
While walking sideways for five seconds, the robot also makes sounds and displays text on the NXT screen to say which direction it is going left or right. Then follow the instructions in Figure and Figure to create the program. The program should keep running until you manually abort it, so you use a Loop Block.
Inside the loop, you place two Switch Blocks to tell whether a sensor is pressed. For example, when you press the Touch Sensor connected to port 1, the Strider robot should start to walk to the right and because of the Wait Block keep going in this direction for five seconds.
Next, it should go back to the beginning of the program to see whether a sensor is pressed. If no sensor is pressed at that point, the Strider should continue to walk forward. The blocks you configured in steps 1 and 2 form the basis of this program. At this point, download the program to the Strider to test it. Figure Step 3: Here you add the blocks that should be run when the right Touch Sensor is pressed.
Next, the Strider robot should walk to the right because of the Walk-Right My Block that you placed earlier. Figure Step 4: The blocks you place here are similar to those in step 3, except that they are run when the left Touch Sensor is pressed. Consequently, the Sound and Display Blocks are configured to tell that the robot is walking to the left.
Congratulations, you can now download and run the program to make Strider walk! Can you create a new My Block that uses the same Motor Blocks but that flips all motor directions? Which way does Strider walk now? Do the same thing for the other two My Blocks so that Strider can walk in six different directions. But before you create this program, you need to learn two new programming tricks: Feedback Boxes and thresholds.
Feedback Boxes as shown in Figure display sensor values when the robot is connected to the computer, either through USB or through Bluetooth. Figure A Feedback Box reports sensor values. Figure You use a threshold trigger value to set the edge between light and dark.
You set this value in the Configuration Panel of a block set to work with a sensor, such as the Wait Block shown here. In this case, any value greater than 30 will be considered light, and values 30 and less will be dark. As a result, this block makes the robot wait until the Light Sensor reports a value greater than 30 before the program continues. Unlike a mechanical sensor that is either switched on or switched off, light can have many measured values.
Threshold values are unique to every situation and will likely vary depending on the light conditions in the room. To set the threshold value, you begin by deciding how you want to define the light conditions in your program a room with the lights on and the same room with the lights off , and next you measure the light value in each case. For dark conditions, I measure a value of 4, and for bright conditions I measure a value of 30 with the Feedback Box method.
Your measurements may vary. Once you have the two measured values one for the dark room and one for the light one , you calculate the average of the two, as shown in Figure Your measured values may differ; be sure to calculate your own thresholds using your own measurements.
Figure The threshold is the average of the Light Sensor value found in the dark room a low number and the one found in the room with the lights on a bigger number. To calculate the average, add both values, and divide the total by 2. Create a new program, store it on your computer as Strider- Scared, and follow the instructions shown in Figure Figure After making the Strider move forward, the program waits until the measured light intensity exceeds the threshold set to 17 here.
Once the threshold is exceeded, all motors stop, and the robot makes a loud sound. The last block waits until the sensor sees that it is dark again, at which point the loop restarts and Strider starts walking again. Difficulty: Hard With your My Blocks, Strider walks at the speed specified in the Motor Blocks, but you can make it walk faster or slower by configuring these blocks differently.
Create a program that makes the robot walk faster, based on its Light Sensor readings. If the Light Sensor value is less than 33, make Strider go slow; if this value is between 34 and 66, make it walk faster around 50 percent motor power ; and if the value is greater than 66, make it run as fast as possible without breaking its legs!
Use Switch Blocks to determine the Light Sensor value. You could point a flashlight at the sensor from a distance to make the robot go faster. You can download building and programming instructions for this NXT 2. Now, before you move on to your next robot, take the time to improve your building and programming skills in Building Discoveries 8 and 9 and Discovery What happens if you put this triangle on wheels?
Remove the legs from the motor compartments, and attach wheels without the rubber tires to them, as shown in Figure Try to run the programs you made for the Strider robot.
Do they still work? What happens if you attach the rubber tires? Difficulty: Medium Do you remember the remote control you made for the Shot-Roller? Remove the antennas from the Strider robot, and use the Touch Sensors with long cables as remote buttons.
How do you program Strider to walk in multiple directions? When you built the Discovery robot with the two bumpers in Chapter 7, it almost never got stuck because it could always turn away from the walls it ran into. This is not the case for Strider because it cannot turn around. To make sure the robot never gets stuck, Strider needs to be able to sense the walls from any direction.
It can already see things ahead of it with the Ultrasonic Sensor. Now, remove the antennas from the Strider, and create special bumpers on the two other sides of Strider. Can you use Touch Sensors to build bumpers so that this robot will not crash into objects?
In earlier chapters you configured each programming block by entering the desired settings in the Configuration Panel. One of the fundamental concepts in this chapter is that blocks can configure each other. For example, one block can instruct a Motor block to run a motor at a certain power level.
Blocks transfer information such as the power level using data hubs and data wires. To make this a bit more tangible, think of this as like a person who uses a wired phone to ask someone to set the radio to half of its maximum volume, as shown in Figure The two people here represent programming blocks. The actual phone is the data hub, and the phone wire is the data wire. Figure You use data hubs the phones and a data wire the phone wire to carry a value the radio volume from one programming block the person on the left to the other the person on the right.
The second block uses the value to turn on the radio at the requested volume level. For the volume value to move from the first to the second programming block, it goes from the block through a data hub the phone on the left , through a data wire the phone wire , and through another data hub the phone on the right ; when it reaches the second block, it specifies its volume setting.
A data hub, which is part of a programming block, allows a block to pass values into the wire the data hub on the left of Figure and retrieve values from it the data hub on the right of Figure This chapter teaches you how to make programs that use data hubs and data wires. Now build SmartBot by following the instructions on the next few pages, but first select the required pieces, as shown in Figure For example, if you keep a book close to the sensor and run the program, the hand should go up and down slowly, but move faster if you run the program again with the book farther away.
Figure Step 1: Place all the necessary blocks for the Smart-Intro program on the Work Area, and configure them as shown here. You should already see a small data hub just below the Ultrasonic Sensor block, but you can open the complete data hub by clicking the same tab.
Figure Step 3: Create and connect the yellow wire as shown here. The yellow line is the data wire. Download the program to SmartBot, and run it while keeping a book about 20 cm 8 inches away from the Ultrasonic Sensor.
Next, run the program again with the book about twice as far from the robot. You should notice that each time you run the program, the Hand motor turns at a different speed. The first Sound block simply plays a sound. Once the sound finishes playing, the Ultrasonic Sensor block polls the sensor once, resulting in a reading of, say, 35 cm. The yellow data wire then carries the sensor measurement to the other end of the wire to the Motor block, which then makes the Hand motor turn for three seconds, as specified in its Configuration Panel.
Figure shows an overview of what happens. Figure An overview of the Smart-Intro program. The Ultrasonic Sensor block polls the sensor and sends the sensor value through a data wire to the Motor block, which uses this value to set the motor speed. As you can see, you use a data wire to carry information between blocks. You created the data wire by first clicking one of the data plugs on the data hub of the Ultrasonic Sensor block.
Next, you connected the other end of the wire to the Power data plug on the hub of the Motor block. As a result, you actually reconfigured the Power setting of this block, and the motor moved at a speed based on the sensor reading. To close the hub, click the tab again. Move your mouse pointer over the data plugs to figure out what each plug stands for. As you mouse over the various plugs on the data hub, you should see which setting is reconfigured when you connect a wire to this plug. It will start out slowly and increase its speed until it reaches the maximum power level.
To make this program, you place a Motor block that makes the motor turn for half a second inside a Loop block. Because the Motor block is inside the loop, the motor keeps spinning. When you start the program, the loop count is 0, which makes the motor run at zero speed it stands still for half a second as specified by the Duration setting.
When it repeats, the motor speed is 2, and so on. Follow the instructions in Figures and to create the Smart-Accelerate program. Download this program to your robot, and run it. Figure Step 1: Place and configure the two blocks as shown here. Note that the Counter setting is checked in the Loop block, which opens a little plug on the left side of the Loop block.
The hubs contain two types of plugs, as shown in Figure output plugs on the right side and input plugs on the left side. Output plugs carry out a value and pass it to a data wire. For example, the Distance plug on the Ultrasonic Sensor block carries out the measured distance value. For example, you used the Power plug as an input plug.
Generally, a data wire carries information from an output plug of one block to an input plug of another block. Figure Input and output plugs on a data hub.
The data wire carries information from an output plug to an input plug of another block. As a general rule, the data wire input overrides the setting specified in the Configuration Panel, and the setting in the Configuration Panel is ignored, as illustrated in Figure All other settings that do not conflict with a data wire are in effect, as specified in the Configuration Panel. For example, the block here will make the motor turn forward because the Configuration Panel says so. Figure To delete a data wire that connects two blocks, click the data plug on the right end of the wire.
Difficulty: Easy Create the program shown in Figure The Display block shown in the figure will display a circle in the middle of the NXT screen. You want the circle to grow bigger as you wait, so the Radius setting should increase over time. The program here is incomplete, because a data hub and a data wire are missing.
Can you open the data hub and connect the data wire to finish this program? Figure The incomplete program for Discovery Can you complete it by connecting a data wire appropriately? Difficulty: Medium The Smart-Intro program polled the Ultrasonic Sensor once and used the sensor value to set the speed of the Hand motor.
You can modify this program so that the motor speed is continuously updated with a new sensor reading as follows: 1. Remove the Sound block. Place the two remaining blocks in a Loop block configured to loop forever. If the data wire breaks as you do so, reconnect it. Now as the program runs, move the SmartBot back and forth near a wall so that the Ultrasonic Sensor constantly measures a different distance. What happens to the motor speed? Can you figure out why this happens?
The final way to poll sensors is with Sensor blocks, as shown in Figure These blocks are useful if you want to retrieve a sensor value and transfer it to another block with a data wire, as you saw with the Smart-Intro program. Sensor blocks are of no use on their own; they must be connected to another block with a data wire in order to function.
Sensor blocks simply transmit sensor readings to other blocks with data wires. In addition to polling sensors, Sensor blocks can also compare a measured sensor value with a trigger value. Generally, these blocks have two output plugs. Recall that the Color Sensor can function as a Light Sensor.
Once configured in this way, when you subsequently connect a data wire to the Detected Color plug, it should carry out a value from 0 to , based on the brightness of the detected light is brightest. Figure You can find a Sensor block for each sensor on the Complete Palette. If you rotate the motor backward see Figure , the output value will be negative. Examples of information carried by Number data wires are Ultrasonic Sensor readings and loop counts.
These wires are often used to define settings of a block that can have only two values, such as the turn direction of an NXT motor. For example, a motor will spin forward when a Logic data wire with the value true is connected to the Direction plug of a Motor block. Consequently, it spins backward when the Logic data wire value is false. Figure Examples of three types of values. This mismatch results in a broken data wire, because the given information cannot be used.
This plug will output a logic value either true or false , based on the result of the Compare box in the Configuration panel. The Ultrasonic Sensor block will check to see whether the sensor reading is smaller than the trigger value 40 cm. If it is, the result is true; if not, the output value is false. Now create the Smart-LogicWire program as shown in Figure This text can be a word, like Hello, as well as sentences like My name is Mike.
OverDrive Borrow eBooks, audiobooks, and videos from thousands of public libraries worldwide. New here? We use this information to create a better experience for all users. Please review the types of cookies we use below. These cookies allow you to explore OverDrive services and use our core features. Introduction to Machine Learning, fourth edition. Ethem Alpaydin. Embodied Computing.
The Future of Brain Repair. Beyond Bakelite. Joris Mercelis. Abolish Silicon Valley. Craig Watkins. Samsung Rising. Geoffrey Cain. Related Articles. Looking for More Great Reads?