Project 2: Robot Arm

Sound activated robot arm

Just Arm Whole Arm

Overview & Research

For this project I really wanted to push myself and tackle a project that would require a much greater understanding than we were just being taught. So with such a large area to cover I didn’t know where to really start, but I got thinking about robot arms and how there are so many things you can do with them and once an initial code is set out they are relatively easy to develop; and who doesn’t like a big ass robot arm!!

Doing my research I found that a lot of people had created arms that where controlled via a joystick or mouse, however I wanted to do something slightly different that I haven’t seen someone do yet. I wanted to create a sound activated arm that on a command would pick up an object and move it to a second location.

Below is a video of an arm being controlled via a computer mouse.

So initially I wanted it voice activated and the arm to have a sensor on the end that could find objects wherever their location. But due to the time frame this was going to take too long but could still be a development process later on as I stated earlier. The simplified version though would be just as good, the arm would respond to a set number of claps or clicks to tell it where to go, and the item it needed to pick up would be in a set locations.

I began sourcing parts as being a more technically challenging project a lot of the components I had to obtain from china to keep the costs down. It was then onto the code where the first challenge was to try and get my sound sensor working by getting a simple LED to turn on, this guy was a great help in the early stages:

Once accomplished it was the task of getting the arduino to count the number of times it heard a clamp, to do this I used a counter function that added one to the counter every time it heard a sound above a certain threshold e.g.

if (sensorReading >= 60)



The challenge now was to set a time limit so after a period of time it would perform the action that matched the number of counts. So I looked into millis and the way it would keep looping around a function until the time period was up, the bold engineer was of great help here.

unsigned long interval = 4000;

unsigned long currentMillis = millis();

It was then just a series of if statements that said if the counter = 1 then perform this task and if it = 2 then perform a different task.

My code can be shown below but I’ve left out the tasks in the if statements as they are very long and personalized to my rig, however I will provide an example.

#include <Servo.h>

const int ledPin = 13;

const int ledPin2 = 12;

const int ledPin3 = 11;

const int ledPin4 = 10;

const int knockSensor = A0;

const int threshold = 20;

Servo myservo;

Servo myservo2;

Servo myservo3;

Servo myservo4;

Servo myservo5;

Servo myservo6;

int pos = 0;

int sensorReading = 0;

int peaksoundcounter = 0;

unsigned long interval = 4000;

unsigned long previousMillis = 0;

void setup()








pinMode(ledPin, OUTPUT);

pinMode(ledPin2, OUTPUT);


myservo6.write(pos = 15);

myservo5.write(pos = 0);

myservo4.write(pos = 70);

myservo3.write(pos = 140);

myservo2.write(pos = 50);

myservo.write(pos = 50);


void loop()


sensorReading = analogRead(knockSensor);

unsigned long currentMillis = millis();

if (sensorReading >= 60)




Serial.print(“numer of peaks: “);


digitalWrite(ledPin2, LOW);


digitalWrite(ledPin2, HIGH);


if ((unsigned long)(currentMillis – previousMillis) >= interval)




for(pos = 0; pos < 140; pos += 1)





previousMillis = currentMillis;

if (peaksoundcounter >=0)



digitalWrite(ledPin, LOW);


digitalWrite(ledPin, HIGH);

peaksoundcounter = 0;





Patrick P2 Circuit 1Power supply

The video below shows how the arm worked on its first test. It was a great relief to know that arm reacted as expected without destroying itself, as well as my power problems not causing me any problems.

Hungry Claw

Trouble shooting

So now a basic code had been achieved and the arm worked picking up a single object, I need to create the rig on which the arm would operate. This involved a lot of trial and error to ensure the arm was positioned in the right area and consistently picked up the object.

Once again when the microphone was positioned it was clear that I was going to have trouble with the threshold mark, so this needed adapting to make sure the microphone would work from a reasonable distance (50cm) when a sharp clap was heard.

Although I had solved my power problem earlier I still had a very complicate way of getting both the servos and arduino powered. To solve this I purchased a multi switch which was able to disconnect both circuit but still keep there power separate this meant there was a simple one switch flick to activate the arm.

On Off switch whole circuit board


Looking to the future of this project I would really like to develop it further as I found it a great learning experience as well as great fun to produce. It would be nice to connect the microphone to a voice recognition package such as bitvoicer so that a voice command saying the object you want to pick up could be used. Another feature that could be introduce would be to have a colour or object sensor on the end of the claw which would be able to locate objects by itself, removing the need for a set position the arm has to go to.

Arm Crisps Final circuit Moving Arm