Project 5 Passive Buzzer Sound Production

1.Introduction

Buzzers are divided into active and passive buzzers. Passive buzzers don’t carry with vibrator inside, so it need external sine or square wave to drive. It can produces slight sound when connecting directly to power supply. It features controlling sound frequency and producing the sound of “do re mi fa so la si”.

In this project, with passive buzzer, we use graphical programming to make this buzzer produce sound at 10~5000 frequency.

2.Materials Required

  1. KEYESTUDIO UNO Control Board *1

  2. V5 Sensor Shield*1

  3. Passive buzzer*1

  4. Female to Female Dupont Line*3

3.Connection Diagram

4.Sample Code

int _ABVAR_1_t1;

void setup()
{
    pinMode( 13 , OUTPUT);
    _ABVAR_1_t1 = 0;
}

void loop()
{
    analogWrite(_ABVAR_1_t1, 10);
    digitalWrite( 13 , !(LOW ));
    if (( ( _ABVAR_1_t1 ) < ( 5000 ) ))
    {
        digitalWrite( 13 , !(HIGH ));
        tone(8, _ABVAR_1_t1, 3000);
        _ABVAR_1_t1 = ( _ABVAR_1_t1 + 100 ) ;
        delay( 2000 );
        digitalWrite( 13 , LOW );
        delay( 2000 );
    }
    digitalWrite( 13 , HIGH );
    delay( 1000 );
}

5.Result

Ardublock graphical programming environment offers a buzzer module. There are several parameters, including one buzzer connecting port, and the other one sound frequency.In this project, t1 is a variable to change the frequency of sound producing, which begins from 10, and increases 100 each time, up to 5000. Figure pin 13 is used as prompt, so when making a sound , LED blinks. “Dang”module is a cycle structure on condition that the value of t1 is less than 5000. When more than 5000, the cycle structure ends. Please have a try, to find in which frequency the sound is sweeter from 10 to 5000 in this mystical sound program.

After downloading the program, this passive buzzer project is finished.