Scan Nearby Objects to Make 3d Model Using ARDUINO

4,148

62

3

Posted

Introduction: Scan Nearby Objects to Make 3d Model Using ARDUINO

This project is specific by utilizing the HC-SR04 ultrasonic sensor to scan for nearby objects.

For making 3d model you need to sweep sensor in perpendicular direction.

You can program the Arduino to sound an alarm when the sensor detects an object within a specific vicinity. Connecting it to a computer allows data to be plotted to make a simple sonar scanner. The scanning ability is made possible through the use of a hobby servo motor SG-5010, and an Adafruit motor shield v1.0.

This project could easily be extended to provide object avoidance for any robotics project. This tutorial was designed so that you could see how the components interact, and also to see how you can use and expand the functionality of the motor shield.

Step 1: Parts Required

  1. Freetronics Eleven or any compatible Arduino.
  2. Adafruit motor shield v1.0
  3. HC-SR04 Ultrasonic Sensor
  4. MG-995 or SG-5010 Standard servo
  5. Mini Breadboard 4.5cm x 3.5cm
  6. Female header pins to allow easy access to the analog pins on the Motor Shield
  7. Piezo buzzer - to sound alarm
  8. 9V Battery and Battery Clip
  9. Wires to connect it all together

Gauge parts

  1. Paper (to print the face of the gauge), and some glue to stick it to the wood.
  2. MDF Standard panel (3mm width) - for the top and base of the gauge, and the pointer.Galvanized bracket (25x25x40mm)
  3. Timber screws: Hinge-long threads csk head Phillips drive (4G x 12mm)Velcro dots - to allow temporary application of the mini-breadboard to the gauge.
  4. The gauge was used as a customisable housing for the Arduino and related parts, and to provide some visual feedback of the servo position.

Step 2: Schematics

  1. The Servo motor can be connected to either of the Servo motor pins (Digital 9 or 10). In this case, the Servo is attached to digital pin 10.
  2. Make sure you read the servo motor data sheet and identify the VCC (5V), GND, and Signal connectors. Not all servos have the same colour wires.
  3. My servo motor has a white signal wire, a red VCC wire and a black GND wire. Also when connecting your wires to the HC-SR04, pay attention to the front of the sensor.
  4. It will identify the pins for you. Make sure you have the sensor facing the correct way. In this sketch, the sensor is actually facing towards you.

In this sketch - we connect the :

  1. Echo pin to Analog pin 0 (A0).
  2. Trigger pin to Analog pin 1 (A1)
  3. VCC to a 5V line/pin and GND to a GND line/pin

Pay attention to your motor shield, I have seen some pictures on the internet where the 5V and GND are reversed.

Step 3: Arduino Code

The motor shield requires the Adafruit motor shield driver library to be installed into the Arduino IDE.

Notes:

  • Servo Angles: You will notice on line 22, the maximum servo angle used was 176. This value was obtained through trial and error (see below).
  • Calibrating the servo angles You may need to calibrate your servo in order to move through an angle of 0 to 180 degrees without straining the motor. .
  • Go to line 21-22 and change the minAngle to 0 and the maxAngle to 180. Once you load the sketch to the Arduino/Freetronics ELEVEN, you can then open the Serial Monitor and type a value like 10 , and then keep reducing it until you get to 0.
  • If you hear the servo motor straining, then move it back up to a safe value and change the minimum servo angle to that value. Do the same for the maximum value.
  • In this example, the servo's minAngle value was 0, and maxAngle value was 176 after calibration, however, as you can see from the video, the physical range of the servo turned out to be 0 to 180 degrees.

Step 4: The Processing Sketch

You can download the Processing IDE from this site.

Step 5: The Output

Hope you like it. Please give thumbs up.

Share

    Recommendations

    • Science of Cooking

      Science of Cooking
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Spotless Contest

      Spotless Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    2 Comments

    That's a cool idea! If you swept the sensor through a perpendicular direction, you could potentially make a 3D model of the room.