Delivery throughout Europe

Ordered before 16:00 = Shipped today

Fast delivery with DHL

XNUMX days return *


Country

Have you always wanted to add sound or music to you Arduino projects? It's easier than you think!

In this project I will show you how to play a song using a buzzer. We are going to let the Arduino Father Jacob play by adjusting the hertz of the buzzer. By adjusting the frequency we can play higher and lower tones.

The way a buzzer makes this frequency is as follows. There is a magnet in the buzzer that goes back and forth through electrical pulses. This magnet then hits a thin plate or sheet, which then vibrates at a certain frequency, creating sound.

  • Level - Beginner 30% 30%
  • Duration - 10/15 Min 30% 30%
  • Costs - € 35,84 euros complete 30% 30%

Step 1: Requirements

1X Arduino UNO

1X breadboard

2X M / M jumper wires

1X piezo buzzer

Step 2: Building and Wiring

Wiring this project is quite simple. I / O pin 9 goes to the plus of the buzzer, from the ground on the Arduino a cable goes to one side of the resistor and make sure the other side of that resistor is connected to the minus of the buzzer.

Step 3: Programming

 

To make the Buzzer Father Jacob play, we make a simple code.

You just need to define pin 9 and give the tones the correct frequency and rhythm.
Then you put the frequency values ​​in succession with a rhythm of 120 bpm (beats per minute).

When you have done that and you upload the code to your Arduino, he will play father Jacob. It is also possible to play other songs with a buzzer. If you want, you just need to change the notes and their frequency.

 

// definition of the pin where the buzzer is

const int buzzer = 9;

 

// here we define pin 9 as output

void setup () {

  pinMode (buzzer, OUTPUT);

}

 

// here we make our song

void loop () {

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 2349);

   delay (500);

   tone (buzzer, 2637);

   delay (500);

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 0);

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 2349);

   delay (500);

   tone (buzzer, 2637);

   delay (500);

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 2637);

   delay (500);

   tone (buzzer, 2794);

   delay (500);

   tone (buzzer, 3136);

   delay (1000);

   tone (buzzer, 2637);

   delay (500);

   tone (buzzer, 2794);

   delay (500);

   tone (buzzer, 3136);

   delay (1000);

   tone (buzzer, 0);

   tone (buzzer, 3136);

   delay (250);

   tone (buzzer, 3520);

   delay (250);

   tone (buzzer, 3136);

   delay (250);

   tone (buzzer, 2794);

   delay (250);

   tone (buzzer, 2637);

   delay (500);

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 3136);

   delay (250);

   tone (buzzer, 3520);

   delay (250);

   tone (buzzer, 3136);

   delay (250);

   tone (buzzer, 2794);

   delay (250);

   tone (buzzer, 2637);

   delay (500);

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 0);

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 1568);

   delay (500);

   tone (buzzer, 2093);

   delay (1000);

   tone (buzzer, 0);

   tone (buzzer, 2093);

   delay (500);

   tone (buzzer, 1568);

   delay (500);

   tone (buzzer, 2093);

   delay (1000);

   tone (buzzer, 0);

}

The rating of www.elektronicavoorjou.nl at WebwinkelKeur Reviews is 9.3/10 based on 4991 reviews.