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.
Materials Required:
- 1. KEYESTUDIO UNO Control Board *1
- 2. V5 Sensor Shield*1
- 3. Passive buzzer*1
- 4. Female to Female Dupont Line*3
Connection Diagram:
After wiring, we can start programming.
Click “download to Arduino” to see the following codes in IDE interface:
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 ); } *******************************************************************************
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.
All Projects
- ARDUBLOCK Graphical Programming Starter Kit Tutorial
- ARDUBLOCK Project 1: LED Blinking
- ARDUBLOCK Project 2: PWM Regulating Light Brightness
- ARDUBLOCK Project 3: Flowing Light
- ARDUBLOCK Project 4: Button-controlled LED
- ARDUBLOCK Project 5: Passive Buzzer Sound Production
- ARDUBLOCK Project 6: Active Buzzer Sound Production
- ARDUBLOCK Project 7: Reading-out Analog Value
- ARDUBLOCK Project 8: Light-controlled Sound
- ARDUBLOCK Project 9: Sound-controlled Light
- ARDUBLOCK Project 10: Servo Motor Control
- ARDUBLOCK Project 11:Ultrasonic Distance Measurement
- ARDUBLOCK Project 12:PS2 Joystick Module
- ARDUBLOCK Project 13: LM35 Temperature Sensor
- ARDUBLOCK Project 14: 5V Relay Module
- ARDUBLOCK Project 15: Tilting Switch Module
- ARDUBLOCK Project 16: Capacitive Touch Module Control LED
- ARDUBLOCK Project 17: Flame Alarm Module
- ARDUBLOCK Project 18: Reed Switch Module
- ARDUBLOCK Project 19: Human Body IR Pyroelectricity
- ARDUBLOCK Project 20: Line Tracking Sensor
- ARDUBLOCK Project 21: MQ-2 Combustible Gas and Smoke Sensor
- ARDUBLOCK Project 22: Soil Module
Buy it >> ARDUBLOCK Graphical Programming Starter Kit for Arduino