Hobbies And Interests
Home  >> Hobbies >> Other Hobbies

DIY: Ultrasonic Robot Control

Robots use a variety of electronic sensors to sense the objects around them and control their movements. An ultrasonic range finder tracks the distance between an object, such as a wall or table, and itself by emitting an ultrasonic signal and waiting for that signal to reflect back. To use the range finder, connect it to the microcontroller controlling your robot and modify the microcontroller's code to accept data from the range finder and change the robot's behavior based on the received information.

Things You'll Need

  • Single-core or multi-core wire
  • Ultrasonic range finder
  • Microcontroller
  • Computer cable
Show More

Instructions

    • 1

      Use single-core or multi-core wire to connect the ultrasonic range finder's pins to the microcontroller controlling the robot. The pins are the metal pieces protruding from the sensor. Connect them to the voltage output, ground and input terminals on the microcontroller. If you don't know which pins to use on the sensor, look at its datasheet to determine which pin is which.

    • 2

      Connect the microcontroller to the computer with a compatible computer cable, so you can modify its program.

    • 3

      Launch the microcontoller's programming software on the computer.

    • 4

      Write code to create a variable called "sonicReading." The variable stores incoming data from the ultrasonic range finder in the microcontroller's program.

    • 5

      Write code to set the pin connected to the ultrasonic range finder's output as an input. This allows the microcontroller to read the data coming from the ultrasonic range finder.

    • 6

      Write code that reads the data from the microcontroller's input that's connected to the ultrasonic range finder, and stores the data in the variable called "sonicReading."

    • 7

      Write statements, such as "if" and "else if" statements, that modify the robot's movements based on the data stored in "sonicReading." For example, if the value stored in "sonicReading" indicates an object is nearby, tell the robot to turn, reverse or stop, else if the value indicates no objects are nearby, tell the robot to continue moving along its path.

    • 8

      Upload the code to the microcontroller.

    • 9

      Disconnect the microcontroller from the computer.


https://www.htfbw.com © Hobbies And Interests