Drawing Arm That's Controlled by Sound - Arduino School Project

3,305

28

4

Introduction: Drawing Arm That's Controlled by Sound - Arduino School Project

This is my very first time working with Arduino, and working with something like this ever, so sorry if I made any mistakes! I got this idea when I thought about my hobbies, which are drawing and music. So I tried to combine the two into this! A self-drawing arm that's affected by sound.

Step 1: Step 1: Materials

- Arduino Uno

- Breadboard

- Sound detector (Sparkfun sen-12642)

- 2 (mini) Servo's

- Tie wraps / zip ties

- Some wood and paper

- something you can draw/write with

Step 2: Step 2: Setup

I first plugged in the Servo's and then the sound detector. The Sparkfun sen-12642 sound detector has 3 outputs, I only used the "envelope" output.

Servo 1 = pin ~9

Servo 2 = pin ~10

Sound detector = pin A0

The red lines(5v) are connected to the positive side on the breadboard, and the black lines(ground) are connected to the negative side.

Step 3: Step 3: Non-electronics

Make sure the servo's are steady and in the right place. I used tie wraps to steady them. After that I used tie wraps to tie the (replaceable) upper parts of the servo to the wooden arms. After that you can connect the wooden arm parts to the servo's. Connect all the wires to the Arduino and breadboard.

After that I soldered the wires to the sound detector.

Step 4: Step 4: Code

I'm in no way near being good at coding, but I tried my best and the internet helped a lot :)

#include <servo.h>
Servo myservo1; Servo myservo2; int pos = 0; int PIN_ANALOG_IN = A0;

void setup()
{ Serial.begin(9600);

// Display status Serial.println("Initialized"); myservo1.attach(9); myservo2.attach(10); }

void loop() { int value;

// Check the envelope input value = analogRead(PIN_ANALOG_IN);

// Envelope value affects the servo's Serial.println(value); if(value <= 5) { myservo1.write(random(40, 50)); myservo2.write(random(40, 55)); } else if( (value > 5) && ( value <= 10)) { myservo1.write(random(35, 55)); myservo2.write(random(35, 60)); } else if((value > 10) && (value <=20)) { myservo1.write(random(30, 60)); myservo2.write(random(30, 65)); } else if((value > 20) && (value <=30)) { myservo1.write(random(25, 65)); myservo2.write(random(25, 70)); } else if((value > 30) && (value <=60)) { myservo1.write(random(20, 70 )); myservo2.write(random(20, 80)); } else if((value > 60)) { myservo1.write(random(0, 90)); myservo2.write(random(0, 90)); }

delay(180); }


Be the First to Share

    Recommendations

    • Explore Science Challenge

      Explore Science Challenge
    • Barbecue Speed Challenge

      Barbecue Speed Challenge
    • Toys & Games Contest

      Toys & Games Contest

    4 Comments

    0
    H_salem
    H_salem

    1 year ago on Step 4

    Hello Leniuu ,
    Thanks for sharing this and your explanation. I am also building a robot that draws according to the sound. it is pretty much as urs. I would like to ask you about the product that your Robot makes at the end. I am trying your codes on mine " if you don't mind" but I am still don't know what is exactly the factor that makes the robot move. Is it the loudness of the voice or the sharpness or the Pitch ?
    I am sorry if my question sound a bit stupid. I have no great knowledge in coding and this is my very 1st attempt.

    thanks in Advance.

    0
    Keman
    Keman

    Question 2 years ago

    Hello, have You tried to replace servo with stepper motors ?

    0
    Swansong
    Swansong

    3 years ago

    That's a pretty fun idea! Do you have a video of it in action?