Learning Math and CS with Robotics
Sign In
Use Ultrasonic Sensor to Measure Distance (grade 6+)
  • Lessons for new concepts
  • Activities for homework


Learn how to use RoboBlockly's "LArduino" commands to measure distances and avoid collisions, using an ultrasonic sensor plugged in to an Arduino board that is connected to a Linkbot robot.

Hardware needed:

Barobo Linkbot Advanced Kit:

Barobo Robot Sensor Pack:


Software needed:

RoboBlockly at www.roboblockly.com (free)


Connecting the ultrasonic sensor:

As shown in the first image below, the VCC pin of the sensor is connected to the 5V pin in the Power section of the Arduino, and the Gnd pin of the sensor is connected to one of the GND pins in the same section. The sensor's Trig pin is connected to digital pin 9, and the Echo pin is connected to digital pin 8. The image also shows how the green, red, and black wires from the white cable connector plug into the A5, A4, and GND pins, respectively. The other end of the white cable plugs into the top of the Linkbot, as shown in the second image below, with a complete view of the Linkbot-Arduino-Sensor connections (plus an LED module attached using wires instead of the direct plug-in method used in the "Blink RGB LED with LArduino" activities).