Obstacle Avoidance Robot (Pinky) – Part 3

Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Ultrasonic sensor (HC-SR04) is the most important part in an obstacle avoidance robot. Before we can used the HC-SR04, we need to include the library. To do so, go to the Arduino IDE and click Sketch > Include Library > Manage Libraries and then search SR04 from gamegine.

#include <PWMServo.h>
#include <HCSR04.h>

HCSR04 hc(4,7);    // initialisation class HCSR04 (trig pin , echo pin)

PWMServo myservo;  // create servo object to control a servo
float distance;

void setup() {
  myservo.attach(SERVO_PIN_A);  // attaches the servo on pin 9 to the servo object
  Serial.println("Test Ultrasonic + Servo Fix 90 Degree");

void loop() {
  distance = hc.dist();

Obstacle Avoidance Robot (Pinky) – Part 1

Part 1 | Part 2 | Part 3 | Part 4 | Part 5

In robotics, obstacle avoidance is the task of satisfying some control objective subject to non-intersection or non-collision position constraints or in other words, an Obstacle Avoidance Robot is an intelligent robot, which can automatically sense and overcome obstacles on its path.

Before we can do an obstacle avoidance robot, we need a brain (microcontroller), robot chassis, dc motor, dc motor driver and ultrasonic sensor/infrared. However, a few things we need is a jumper wire, toggle switch (to turn ON/OFF battery) and battery.


Maker Uno, an Arduino UNO compatible board designed and developed specially for students/hobbyist to learn coding and microcontroller. The best part of Maker Uno is the built-in LEDs as an indicator, a buzzer (Pin 8) and onboard programmable button (Pin 2).

Maker Uno

Robot Chassis (Including dc motor and caster)

Aluminum Chassis in Blinka purple makes for an excellent robot body. It’s a single piece of bent 2mm thick aluminum, with a variety of holes, slots and cutouts for mounting boards, sensors, and servos. The sides are notched to fit two DC Gear ‘TT’ motors perfectly.

Motor Driver

Maker Drive is a simplifying H-Bridge motor driver for beginner.

Ultrasonic Sensor

HC-SR04 is a sensor for distance measurement and object detection.
Ultrasonic sensor is created based on the principle of echolocation used by animals like bats and dolphins. Since ultrasonic sensor uses sonar to determine the distance to an object, its operation is not affected by sunlight, spotlight and object’s surface color which will affect the readings of any infrared distance sensors. However acoustically soft materials such as clothes can be difficult to detect.

Lastly, for improvement for future development, we can add a servo motor (will be discussed in Part 2) for ultrasonic rotation. Tower Pro SG90 micro servo motor is a low-cost plastic gear RC servo with 1.80kg.cm holding torque (at 4.8V). It is a perfect solution for robotic projects.

Therefore, this is a common electronic and hardware parts for developing an obstacle avoidance robot. The name of the robot is Pinky! :).