The NXT device Why use Enchanting and not NXT software? Progression from Scratch Create with users in mind Easy install(windows)The motor block Brick The different sensors Light Sound Touch Ultrasound
What is it?Who created it? Enchanting is a programming environment for LEGO Mindstorms NXT. It was built to provide an easier way to do more with the NXT. Provide more success and less frustration.SABRESouth Alberta RoboticsHead of SABRE: Clinton Blackmore
The codeIt is very similar to scratch except it has more options:Driving And Motors making it easier to usewith Robots
Configuring a Sensor (tell your NXT what is plugged into it, and where)Suppose we have an NXT with a light sensor connected on port 3. How do we tell Enchanting this?1. Click on the“Sensing” palette.2. Click on the“Conﬁgure Sensors”button. A dialogcomes up.3. Find the light sensorconﬁguration block onthe left-hand side of the 6. Press “OK”.dialog. Drag it to“Sensor Port 3” anddrop it there.4. Choose what sort oflight sensor you have. 7. You now have 5. Optionally, give it a descriptive name. new blocks to use! 0 http://enchanting.robotclub.ab.ca
Morse Key Morse Key GET$READYPress a button to make a sound. Select the palette, and click on the button [it is above all the light blue blocks]. Conﬁgure a touch sensor, like this: Make sure that your touch sensor is on port 1 on the actual robot. Name it. TRY$THIS$CODE Be ep! DO$IT! Click the and wait for the program to run on the robot. Press and release the touch sensor. What happens? GO$FARTHER What would happen if you changed the note or the YOU$NEED duration? An NXT with a touch sensor connected to port 1. Where could you use or ? 1 http://enchanting.robotclub.ab.ca
Range Finder Range Finder GET$READYSee how far away something is. From the palette, choose the button. Conﬁgure a ultrasonic sensor. Make sure the port you conﬁgure it for matches the port the real ultrasonic sensor is plugged into! TRY$THIS$CODE DO$IT! Click the and wait for the program to run. YOU$NEEDAn NXT with an ultrasonic sensor Point the ultrasonic sensor at different objects. connected to port 4. What do you see on the screen? GO$FARTHER What are the largest and smallest values you see? 2 http://enchanting.robotclub.ab.ca Are there any gaps where you get no numbers?
Sound Meter Sound Meter GET$READYCreate a sound-level meter. From the palette, choose the button. quiet Conﬁgure a sound sensor. Paint a new costume for the sprite -- make it a dot! TRY$THIS$CODELOUD! YOU$NEEDAn NXT with a sound sensor* DO$IT! GO$FARTHER connected to port 2. Click the and wait Draw a * Not included in all NXT sets. for the program to run. gauge on the background. Whisper, talk, sing, shout, or blow on Adjust how far the meter 3 http://enchanting.robotclub.ab.ca the sound sensor. moves back and forth.
Differential Drive (lets your two-wheel robot drive around)From the palette, choose the button. Conﬁgure a differential drive. The robot needs If your robot has two The ﬁrst number embossed on a to know which wheels, it is using a LEGO tire is the tire’s diameter in ports the left and differential drive! millimeters. This tire is 56 mm across. right motors are on so it can steer! Le ft m Po rt oto Po C rt A r Ri gh tm oto r The track width is how far apart the wheels are. Measure from a place on the left wheel to that same place onIf you tell the robot to drive forwards the right wheel. Here, measuring fromand it goes backwards, swap the 9.4 cm the left-most point of the left wheel todirection that you’ve conﬁgured the the left-most point of the right wheel,motors to drive in the drive type. the track width is about 9.4 cm. 4 http://enchanting.robotclub.ab.ca
Square Dance Square Dance GET$READY Drive in a square. From the palette, choose the button. Conﬁgure a differential drive, using the instructions on Card #4. Measure numbers to match your robot. TRY$THIS$CODE DO$IT! Click the and wait for the program to run. Unplug the USB cable and place the robot where you want it to start. Press the orange “enter” button on the NXT. Does the robot “dance” in a square? (Is it conﬁgured properly?) Note that you’ll never get 100% accurate motion. YOU$NEED Press the orange “enter” and dark grey “exit” buttons on the NXT toAn NXT with two driving wheels. quit the program before plugging it back into the computer. What other shapes and patterns could you make the GO$FARTHER robot “dance”? Could you have one robot “dance” a square inside a 5 http://enchanting.robotclub.ab.ca square being “danced” by another robot, at different speeds?
Crash Test Crash Test GET$READY Drive into a wall and then stop. ➔ as on Card #4. ➔ . Conﬁgure a touch sensor for use as a bumper. TRY$THIS$CODE DO$IT! Click the and wait for the program to run. Unplug the USB cable and place the robot where you want it to start. Press the orange “enter” button on the NXT. The robot drives until it hits something. Pick it up and press the YOU$NEED “enter” button again. It drives until it hits something.An NXT with two driving wheels and a bumper (touch sensor) on port 1. GO$FARTHER Can you make the robot say something when it hits a wall, such as, “Ouch, my nose” or “Ooof”? Could you draw eyes on it and make it wince? 6 http://enchanting.robotclub.ab.ca How would you make the robot explore a room? Try it out!
Mexican Wave Mexican Wave GET$READY Shout “go”, and each robot, in turn, ➔ as on Card #4. drives forwards, backwards and ➔ . forwards again. Conﬁgure a sound sensor to listen for the start command. TRY$THIS$CODE DO$IT! This works best if you have a whole line up of robots. The delay for each robot is a couple of seconds longer for the one before it in line. On each robot, click the and wait for the program to run. Unplug the USB cable and place the robot in line. Then, on a signal, you all shout “go” together, and YOU$NEED then, one by one, the robots1+ NXTs, each with two driving wheels do the same wave maneuver! and a sound sensor* on port 2. * Not included with all NXT sets. GO$FARTHER What other displays can you “choreograph”? (“Choreography” is the art of designing of movements, and comes 7 http://enchanting.robotclub.ab.ca from Greek words meaning “dance writing”).
Shy Puppy Shy Puppy GET$READY Robot follows you around and ➔ as on Card #4. wants to be close, but not too close! ➔ . Conﬁgure an ultrasonic sensor. Too far! TRY$THIS$CODE DO$IT! Click the and wait for the program to run. Unplug Too close! the USB cable and press the orange “enter” button on the NXT. Try walking away from the robot. Does it follow? Try going towards Just right! it. Does it shy away? Does it ever stand still? GO$FARTHER What would happen if you made the robot turn? YOU$NEED What do two or more robotsAn NXT with two driving wheels and an together do? ultrasonic sensor pointing forwards Add a face to the robot, make it “speak”, or dress it up! 8 http://enchanting.robotclub.ab.ca
Sparkline Sparkline In , choose the GET$READY button. Conﬁgure a light or colour Graph a changing value. sensor, choosing the one you have. TRY$THIS$CODE YOU$NEED DO$IT! GO$FARTHER Click the to start. What happensAn NXT with a light or colour Move the light sensor if you add in the auto- sensor on port 3. over different colours and shades. calibration blocks? Move it closer and farther from a Try drawing a white line on a surface. Point it at a light. Change black background. 9 http://enchanting.robotclub.ab.ca the angle. What happens? Change the lamp colour.
Follow That Line! Follow That Line! GET$READY Follow a line around. ➔ as on Card #4. ➔ . Conﬁgure and name a light or colour sensor, choosing the type that matches your sensor. TRY$THIS$CODE DO$IT! Click the and wait for the program to run. Unplug the USB cable, place the robot on or beside a line, and press the orange “enter” button on the NXT. Press the dark grey “exit” button to stop the robot. GO$FARTHER What happens if you adjust the numbers? Does the line-following course YOU$NEED make a difference? Can you An NXT with two driving wheels and a follow the edge of a table? light/colour sensor pointing downwards. Where is the best place to put your light sensor? What would you do with a second or third sensor? Draw eyes and 10 http://enchanting.robotclub.ab.ca make them look left and right!
Locator Locator GET$READY Find a nearby object. ➔ as on Card #4. ➔ . Conﬁgure an ultrasonic sensor. TRY$THIS$CODE DO$IT! Click the and wait for the program to run. Unplug the USB cable and press the orange “enter” button on the NXT. Move an object around in front of the robot. Does it turn to follow it? How does it work? GO$FARTHER How would you do this with two sensors? YOU$NEED Can you make the robot ignore a An NXT with two driving wheels wall (and anything else as farand an ultrasonic sensor on port 4. away as it)? Try making it scan in a full circle 11 http://enchanting.robotclub.ab.ca and point at the closest item.
Sumo Sumo (card 1 of 2) THE$PLAN Push your opponent out of a ring. If it has nothing better to do, Trigger Behaviour the robot wanders around. If it sees a foe ahead of it, the Sees edge Retreat robot attacks, trying to push the enemy out of the ring. Arbiter Foe ahead Attack Most importantly, if it sees the edge, the robot retreats Wander from it, in an effort to stay in the ring. GET$READY ➔ as on Card #5. ➔ . Conﬁgure an ultrasonic sensor and a light/colour sensor. Create a bunch of costumes for your sprite, using the text tool to display the following words in large letters, “Countdown”, YOU$NEED “Wander”, “Attack”, “Retreat” and “PressEach competitor needs an NXT with two Button to Start”.driving wheels, an ultrasonic sensor, and a light or colour sensor. ➔ . Create variables named “next action”, “foe ahead”, and “sees edge”. 12A http://enchanting.robotclub.ab.ca
Sumo (card 2 of 2) TRY$THIS$CODE DO$IT! ➔ . You’ll make blocks called “Attack”, “Retreat”, Click“Wander”, and “Startup”. the and wait for the program to run. Unplug the USB cable and place the robot on the sumo board. When you are told to start your robot, press the orange “enter” button on the NXT. GO$FARTHER Can you add other behaviours to the robot, or change some of the existing ones? What could you do to make your sumo robot better? DO$IT! Would this method of programming work for other robots? 12B http://enchanting.robotclub.ab.ca