Skip to content

Getting started with the Range Finder

Set up the PASCObot to maintain a distance from an object using a program provided in the PASCO Code Library. Use the code as-is or as a starting point for coding a more complex program.

What you need

Install the Range Finder

  1. Remove the thumbscrew on the top of the bot and remove the top frame of the PASCObot.
  2. Place the Range Finder module in the front compartment of the PASCObot's bottom frame.
  3. Install two screws to secure the module to the frame. Don't over-tighten them!
  4. Connect the module to the //control.Node's Sensor port using the cable included with the module. Push the cable plugs into each port until you hear a click.
  5. Insert two nuts (included with the PASCObot) in each of the bot's front compartments. This makes the bot front-heavy to help keep the Range Finder sensors pointing forward.
  6. Replace the top frame on the PASCObot and secure it with the thumbscrew.

Set up the software

  1. Turn on the //control.Node and connect it to Capstone.
  2. Select the Code tool and click PASCO Code Library .
  3. Select PASCObot in the Code Library menu, select Maintain Range, and click OK.

You will now see the Maintain Range code in the Code tool workspace. The code includes a function called maintainRange with the parameter x (cm). If you place an object in front of the bot, the bot will move towards the object until the distance is equal to the value of the parameter (in centimeters). If you move the object closer to the bot, the bot will move backwards to maintain the distance specified in the parameter.

Run the program

  1. Enter a value for the x (cm) parameter.
  2. Place a book in front of the bot.
  3. Click Record . The bot will move until its distance from the book is equal to the value of the x (cm) parameter.
  4. Move the book closer to the bot. The bot will move further away!
  5. Move the book away from the bot. The bot will move closer to the book!
  6. Click Stop to stop running the code.

Tip

If the program is not running smoothly, try uploading the code to the //control.Node and run it directly on the //control.Node.

Go further

  • Expand the maintainRange function block and take a look at the code. Can you find ways where the code can be improved?
  • Instead of entering a value in the x (cm) parameter, try using a variable value such as a sensor measurement!