Introduction: Control Arduino Robot Arm With Ultrasonic Sensor

This tutorial is an outline of how to hook up an ultrasonic sensor to a robot arm in order to control the height of the arm. It is a simple tutorial. I used mainly off the shelf components and is basically a plug together job.

This tutorial uses the LittleArm 3D printed Arduino Robot Arm as a base.

Step 1: Parts

  1. LittleArm Brainless Kit
  2. Meped Control Board
  3. Arduino Nano
  4. HC-SR04 ultrasonic sensor

This tutorial is for basically plug-and-play components. In the future I will provide a more scratch-built tutorial. If you have a 3D printer and some extra MG90S servos you can build the LittleArm from scratch instead of getting the kit. The 3D files are here.

Step 2: Plug in the Ultrasonic Sensor

With the MePed board used, plugging in an ultrasonic sensor is super easy. Just make sure you don't put in the prongs backwards. Positive to positive. Negative to Negative.

Step 3: Upload Code to Arduino Nano

The nano nestles into the Meped PCB very well. Go ahead and flash it with the attached code.

You may have to tweak the following lines in the file in order to accomodate differences in how you assembled the LittleArm and what kind of feel and range you want it to have.

if ((readDistance > 3 )&& (readDistance < 30)){
//move the elbow and shoulder some amount desiredAngle.elbow = map(readDistance, 5, 30, 175, 70); desiredAngle.shoulder = map(readDistance, 5, 30, 5, 100); desiredAngle.base = 90; }

You may notice that I have the base set at 90. This is reserved for a future tutorial where I want to use 2 sensor to control the arm up and down and left to right.

Step 4: Enjoy the Arm

It is not a very impressive build but it can be a lot of fun. But the expansion is going to be even greater. It is a good introduction for kids that are just starting to use the Arduino and sensors.