The Sound Recreater V2!!! (My Second Instructable)

by aswathmurari123 in Circuits > Arduino

58 Views, 1 Favorites, 0 Comments

The Sound Recreater V2!!! (My Second Instructable)

IMG_1353.jpeg
IMG_1351.jpeg

This project brings together sound and motion to make a tiny robot that can sing and drum at the same time!

A passive buzzer plays the song, while a servo motor moves like a drumstick, hitting the beat every few seconds to act like a bass drum.

You can load simple tunes (like Twinkle Twinkle Little Star or your favorite song), and the servo will tap along with the rhythm giving your music a live performance feel! 🎶

This is Version 2, where we attach a pencil or stick to the servo horn so it can hit a surface like a real drum.

Downloads

Supplies

Arduino Uno – 1 piece (main controller)

⚙️ Servo Motor (SG90 or similar) – 1 piece (moves like a drumstick)

Passive Buzzer – 1 piece (plays the melody)

Jumper Wires – around 6 (for connections)

USB Cable – 1 piece (for power and uploading code)

✏️ Pencil or Small Stick – 1 piece (acts as drumstick attached to servo arm)

Drum Surface – any small box, plastic lid, or paper cup (the surface the pencil taps)

Mount the Servo

  1. Fix your servo onto a small box or table using double-sided tape or glue.
  2. Attach a pencil or stick to the servo horn this is your drumstick.
  3. Make sure it can freely swing up and down without hitting the surface too hard.


Setting Up the Bass

  1. Place a small rubber pad, plastic lid, or cardboard box just under the pencil tip.
  2. When the servo moves down, it should tap the surface lightly.


Giving the Bot Its Voice

  1. Connect the passive buzzer to Pin 8 (positive) and GND (negative).
  2. Remember: passive buzzers can play multiple tones, while active buzzers can only beep.


Uploading Time,

#include <Servo.h>


Servo drumServo;

int buzzer = 8;


#define C 261

#define D 294

#define E 329

#define F 349

#define G 391

#define A 440


int melody[] = {

C, C, G, G, A, A, G,

F, F, E, E, D, D, C,

G, G, F, F, E, E, D,

C, C, G, G, A, A, G

};


int noteDurations[] = {

400, 400, 400, 400, 400, 400, 800,

400, 400, 400, 400, 400, 400, 800,

400, 400, 400, 400, 400, 400, 800,

400, 400, 400, 400, 400, 400, 800

};


unsigned long lastBeat = 0;

int beatInterval = 2000; // Beat every 2 seconds


void setup() {

drumServo.attach(9);

drumServo.write(90);

pinMode(buzzer, OUTPUT);

}


void loop() {

for (int i = 0; i < 28; i++) {

tone(buzzer, melody[i]);

checkAndHitDrum();

delay(noteDurations[i]);

noTone(buzzer);

}


delay(3000); // pause before repeating

}


void checkAndHitDrum() {

unsigned long currentTime = millis();

if (currentTime - lastBeat >= beatInterval) {

hitDrum();

lastBeat = currentTime;

}

}


void hitDrum() {

// Lower servo hit for deeper bass

drumServo.write(135);

delay(200);

drumServo.write(80);

}





upload this code in arduino ide and tweak it accordingly of you servo arm placement.

Personalise the Bot!

🔧 Testing

  1. Connect your Arduino via USB.
  2. Upload the code and open the Serial Monitor (optional).
  3. Watch your servo tap every 2 seconds while the buzzer plays Twinkle Twinkle Little Star!

To change how fast it drums:

  1. Edit the line → int beatInterval = 2000;
  2. 1000 → faster
  3. 3000 → slower chill beat


Other Songs !

int melody[] = {E, D, C, D, E, E, E, D, D, D, E, G, G};

int noteDurations[] = {400,400,400,400,400,400,800,400,400,800,400,400,800};



replace this in the main code and find out what this song is!! !”! !



Things I Could Have Added But I Was Too Lazy


  1. Add an LCD display to show the current song name or beat animation.
  2. Add a button to switch songs.
  3. Add two servos for left-right drum effects.
  4. Include LEDs that flash with the beat.


The Demonstration! and Side View

The buzzer is beside the board.

Downloads

Conclusion With Final Product

I have made this project in succession to its v1 hope you will a blast in creating this beginner friendly project!

Downloads