Arduino Microphone + Servo

Supplies list is:

*Arduino (Mega, Uno, etc.): Nano- Nano, Mega2560 - Mega & power source(or USB)

*Microphone module: microphone sensor.

*5V independent power source (mine is the black board).

*Servo (standard): micro servo.

*& a breadboard.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: The Wiring

This wiring can be done through the Arduino Mega2560, Uno, etc. Servo with yellow pin goes to D2 or digital pin 2. Servo with red pin goes to independent +5V. Servo with black goes to BOTH the Arduino's GND & power source GND. My microphone wiring (can be different) has the black pin going to GND(it will say G on the sensor). The microphone red pin goes to the +5v (doesn't have to be independent) (This is the + sign on the sensor). The microphone white pin goes to D3(meaning Digtal pin 3 (this goes to DO- meaning Digtal Out), (AO is not connected)). If you don't make the power source for the servo independent, you will most likely tear up the efficiency of the Arduino module.

Step 2: The Code (Note That I Can't Put in the Greater Than Sign or Less Than Sign Because of Instructables, So You'll Have to Add That In)

#include Servo.h // include servo library

#define soundSensor 3 // define D3 as soundSensor

Servo myservo; // define servo

void setup()


pinMode(soundSensor, INPUT); // read D3 and take action in the loop

myservo.attach(2); //define servo pin as D2 as output


void loop() {

int SensorData=digitalRead(soundSensor); // This is NOT neccessary, but if you want to remove this you have

//to use the command digitalRead(soundSenor); in the if statement.

if(SensorData==1){ // If you clap, hit the table, etc. do the following:

myservo.write(10); // make the servo go to 0, 10, whatever degree you want

delay(2000); } // hold this position for 2 seconds or 2000 milliseconds

else{ // Or else do the following:

myservo.write(170); } } // go to the degree you want it to go to. Master end.

Step 3: Questions?

If you have any questions about this project, please, comment down below. | Thank you for your time.



Be the First to Share


    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    2 Discussions


    2 months ago

    Sorry, I messed up, this is my first post, so it wasn't too great.