Touch and Go!

 

Remember the program you wrote telling M. Pathfinder to go to a wall and come back. In your solution, you had to modify your program each time the distance to the wall changed. In this activity you will use information from a touch sensor (input) to tell a robot to back up each time it hits a wall, no matter how far away from the wall it is placed.

What you will need:

Your Roverbot

The Robotics Invention™ Kit

Constructopedia, pages 26-29

A disk to save your work

A copy of the Technical Guide

Building Bin

What to do:                                                                                           

  1. Build a single bumper for your Roverbot: Follow the directions in the Constructopedia, pages 26 to 29. 
  2. Look at the bumper you’ve just built. The touch sensor is released (the yellow button is not pushed in). Now, push lightly on the bumper. What happens to the touch sensor?
  3. Connect the bumper to Roverbot.

 

Problem: Make Roverbot move forward towards a wall and move back for 3 seconds after it hits the wall. The main idea here is that Roverbot should be able to move forward any distance before it hits a wall.

 

Here are some blocks that can be used to have the program receive input from a touch sensor.  In each of these blocks there’s a question: “Is the touch sensor pressed?” 

 

 

    Wait Until touch (red)             Yes & No touch (purple)          Sensor Watcher touch (blue)

                                                                                

Tech Guide                    Tech Guide                                Tech Guide                                 

 

© The LEGO Group

A note on Sensor Watchers and Stack Decision Makers

A program can receive input from a sensor using the Stack Decision Makers: Yes or No (purple blocks), Wait Until (red blocks), Repeat While and Repeat Until (orange blocks), or the Sensor Watcher (blue blocks).

Sensor Watcher is just what it says—a block that watches the sensor. So, how is it different from a Stack Decision Maker? While Stack Decision Maker checks for input once, Sensor Watcher looks for input repeatedly. For example, a Yes or No touch Stack Decision Maker asks one time, “Is it pressed? Yes or No!” and keeps going. A touch Sensor Watcher keeps asking over and over, “Is it pressed?” and keeps coming back to the same question even after the program has run.

 

RCXtras

  1. Make Roverbot move until it hits something. Then have it move backwards for a bit, turn a little, and continue to move forward.
  2. Connect two touch sensors to two long connector wires. Write a program that will let you use the touch sensors as remote controls to “take Roverbot for a walk.”
  3. Write a program to have Roverbot zigzag as you press and release the touch sensor. (You can use more than one touch sensor if you want to.)
  4. Build the Table Bumper on page 90 of the Constructopedia. Attach it to Roverbot so that when it’s placed on a table, the wheels touch the table (and the touch sensors are released). Write a program to make Roverbot move on the table and avoid falling off the edge.

Important note: As you try it out, be sure to stand by, prepared to catch Roverbot.

 

Thinking about it

Look at these two blocks. Both get input from a touch sensor. How are they different from each other?

 

What’s the question here?                 

 

 

What will this program do when the touch sensor is pressed?

 

When released?

© The LEGO Group

What’s the question here?

 

 

What will this program do when the touch sensor is pressed?

 

When released?

 

 

Do not take Roverbot apart. You will need it for the next activity.