Sound Sensor & Servo: Reactive Motion

Introduction: Sound Sensor & Servo: Reactive Motion

About: RISD MID 2021

First you need to gather relevant materials to put this circuit together.

Supplies

1 Arduino

1 Ultrasonic Sensor HC-SR04

1 Servo

1 Breadboard

1 9 Volt Battery

1 9 Volt Battery Adapter

3 Black Jumper Wires (Ground/Negative)

3 Red Jumper Wires (Voltage/Positive)

2 Color Jumper Wires (Input/Output)

Step 1: Understanding the Components

It is important before putting together the physical circuit to understand each component:

The breadboard has two sets of power rails on either side, that have slots for negative (black/blue) and positive (red) inputs. They are connected in series vertically. Terminal strips share the connection horizontally, however parallel terminal strips will require a jumper wire to bridge the divider.

The sound sensor has a VCC/5V pin (red), a Ground/GND pin (black) and an output pin (Color). They can have Analog and/or Digital outputs depending on the sensor.

The servo has a 5V port (red), a Pulse Width Modulation/PWM port (color) and a Ground/GND port (black). Click the link to know more about how it works.

Step 2: Setting Up the Circuit

Follow the diagram layout. While setting up the circuit, always remember to keep the arduino unplugged to avoid any damage to your components. In the layout the Sound Sensor is represented by a potentiometer since they work in the same way in terms of code.

Plug the sound sensor into the power rail of the breadboard, taking note of its orientation (this will be important when using the jumper wires to connect to the arduino). Connect VCC with a red jumper wire into breadboard's positive power rail. Connect GND with a black jumper wire into the breadboard's negative power rail. Connect Out pin with a color jumper wire into the Analog Port A5.

Plug the servo into to the breadboard and arduino. Use a color jumper wire to connect it's input/signal port to the digital PWM port, 13 on the arduino. Plug black jumper wire into GND power rail. Plug the red jumper wire into a terminal row. The servo will need extra power which is provided by the 9V battery.

Plug the 9V batter, red jumper wire into the same terminal row as the servo's red jumper wire. The black jumper wire will plug into the same side power rail as the rest of the components.

Step 3: Download Arduino GUI and Input Code

Download Arduino Graphical User Interface (GUI) here.
Plug in the code below, note the information to the right of "//" tells you what that line of code is doing:

----copy below and paste into arduino GUI----

#include

Servo servo_test;

const int soundSensor = A5;

int servoPin = 13;

int soundValue;

int angle;

void setup() {

servo_test.attach(servoPin);

Serial.begin(9600);

}

void loop() {

soundValue = analogRead(soundSensor);

Serial.print("SoundValue = ");

Serial.println(soundSensor);

delay(50);

angle = map(soundValue, 0, 1023, 0, 180);

servo_test.write(angle);

delay(50);

}

Step 4: Sound Sensor + Servo + Arduino

This is how the final circuit should look. Watch the video to see how it works.

Be the First to Share

    Recommendations

    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge
    • DIY Summer Camp Contest

      DIY Summer Camp Contest
    • Stone, Concrete, Cement Challenge

      Stone, Concrete, Cement Challenge

    Comments