Summer Sale: 5% OFF Over $49, Code: Elephant5; 10% OFF Over $99, Code:Elephant10



Arduino Project: Passive Buzzer

Posted by Fiona Su on

Introduction

You can use Arduino to make many interactive works.The most commonly used example is acoustic-optic display. All the previous experiment has something to do with LED. However, the circuit in this experiment can produce sound. Normally, the experiment is done with a buzzer or a speaker while buzzer is simpler and easier to use.
The buzzer we introduced here is a passive buzzer. It cannot be actuated by itself, but by external pulse frequencies. Different frequencies produce different sounds. You can use Arduino to code the melody of a song, which is quite fun and simple.

thumb
Hardware List

  • Arduino Board *1
  • Passive buzzer *1
  • Control board *1
  • Breadboard *1
  • Breadboard jumper wire * 2

Video Tutorial

Connection

Connection for REV4:
Here we connect the passive buzzer to digital pin 8.

thumb

Connection for 2560 R3:

thumb

Sample Code:

int buzzer=8;// select digital IO pin for the buzzer
void setup() 
{ 
pinMode(buzzer,OUTPUT);// set digital IO pin pattern, OUTPUT to be output 
} 
void loop() 
{ unsigned char i,j;//define variable
while(1) 
{ for(i=0;i<80;i++)// output a frequency sound
{ digitalWrite(buzzer,HIGH);// sound
delay(1);//delay1ms 
digitalWrite(buzzer,LOW);//not sound
delay(1);//ms delay 
} 
for(i=0;i<100;i++)// output a frequency sound
{ digitalWrite(buzzer,HIGH);// sound
delay(2);//2ms delay 
digitalWrite(buzzer,LOW);//not sound
delay(2);//2ms delay 
}
} 
} 

Result:

After downloading the program, the buzzer experiment is completed.

thumb

All Tutorial

Buy 

0 comments

Leave a comment

Please note, comments must be approved before they are published