Mentor Sheet 2nd meeting Agenda for October11, 2007 1. Why sensors? 2. Touch and light sensors 3. Forks and loops 4. Touch sensor bumper car 5. Introduce Sumo Challenge Equipment required: Completed taskbot Computer with ROBOLAB 2.9 Touch, light, distance, and sound sensors Worksheets for your student Concepts introduced: Importance of sensors Forks and loops Design planning New icons: NXT Wait for Push NXT Wait for LetGo NXT Wait for Light NXT Wait for Dark NXT Wait for Brighter NXT Wait for Darker NXT Touch Sensor Fork NXT Light Sensor Fork Fork Merge Start of Loop End of Loop Input 1 “Structures” menu “Forks” Submenu “Loops” Submenu All of the “Wait for” icons are found in the “Wait for” menu. The forks are found in the Forks submenu of the Structures menu. The loops icons are found in the loops submenu of the structures menu. Please remember to have your robot charged! 1. Why use sensors? (5 minutes) a. Ask your group what a sensor is. Ans: Allows you to take in some sort of data from the environment. An easy way to think about it is that sensors are similar to the way humans have 5 senses that they can use. b. Why use sensors? Activity i. Select two students and ask them to stand up facing the same direction and walk to some landmark (i.e., wall, desk, trash can, etc.). They should do it without any difficulty. ii. Now have the same two students repeat the activity with their eyes closed and change the directions from walk to a certain landmark to walk a certain number of steps or for a certain length of time. They should end up in different places and not at the landmark. iii. Part ii highlights 2 problems involved with hard coding values instead of using sensors. First, the same commands can produce different results for relatively similar robots. Second, in order to ensure perfect performance, the command must be continually fine-tuned. Using sensors (part i), allows for a robot to operate in a dynamic, changing environment. 2. Introduction to the NXT sensors a. Each NXT kit comes with 2 touch sensors, a light sensor, an ultrasonic distance sensor, and a sound level (dB) sensor. b. These sensors work by taking information from the environment, turning that information into an electric signal, and turning that signal into a set of numbers that the computer can understand and a set of numbers that make sense to humans. c. The NXT’s view menu provides a good general introduction to the sensors. i. Hook up the Distance sensor (must be in Port 4) and use the view menu to get an idea of the readings you get. ii. Repeat with the sound level and light sensors (Can be in ports 1-4) 1. Take note of how light values change on different colors, in different environments (i.e. shade), and at different heights. Explain that the sensor reads from 0-100, where 0 is the darkest reading possible and 100 is the brightest reading possible. 2. BE SURE TO USE REFLECTED LIGHT WHEN TAKING READINGS FROM THE LIGHT SENSOR iii. Because the touch sensor can only be pressed or not pressed, we’ll introduce it in our first programming example of the day. 3. Introducing loops and forks a. You want your robot to go forward until the touch sensor is pressed, stop for 2 seconds, and back up for two seconds. What do you do? The following code assumes that the touch sensor is in port 3. b. What if you want the program to repeat 2 (or any number) of times? i. You could continue to repeat the same code, but after a few times that gets messy and confusing. ii. This is where loops come in handy. They repeat the code contained inside of the loop for the number of times specified. The following code will cause the same program above to run 4 times. The numerical constant is located in the Modifiers menu. iii. There are many different types of loops, several of which may be helpful including the continual loop (the purple one). Use this as an opportunity to show context help (Apple + H or select Help, Show Context Help from the menu). Mouse over a few conditional loops using sensors to show how they work. c. Forks i. Use the context help function to let students figure out how the touch sensor fork functions. Then ask them to complete the following problem. ii. Suppose you want to make some sort of controller that will allow the robot to travel forward for 2 seconds and then turn left or right depending on your desire at that point in time. Develop a code using a fork sensor and continual loop. Note: There are several ways to turn, and the wait fors could be changed to a time or something else. This setup allows for complete control of the length of the turn. 4. Touch sensor bumper cars – similar to avoider, but much simpler… a. Car should explore an enclosed area b. Upon hitting an object it should back up and turn 5. Sumo Challenge – End of year contest, more details to follow