Passive Buzzer

Buzzin’

Preamble

I purchased a Passive Buzzer Module 5V for £0.99

See also Listen!

Links

There is a terrible, nearly in-comprehensible, wiki, from TkkrLab.

Passive Buzzer
Passive Buzzer

Wiring up is simple:

  • GND to GND
  • VCC to 5V, and;
  • I/O goes to whatever pin (13?) of the Arduino that you chose to drive it, which is, then, set as an output. In the example below, pin 8 is used.

A piece of code to drive it:

//Example Code for KY-006
 
int buzzer = 8 ;// setting controls the digital IO foot buzzer
void setup ()
{
  pinMode (buzzer, OUTPUT) ;// set the digital IO pin mode, OUTPUT out of Wen
}
void loop ()
{
  unsigned char i, j ;// define variables
  while (1)
  {
    for (i = 0; i <80; i++) // Wen a frequency sound
    {
      digitalWrite (buzzer, HIGH) ;// send voice
      delay (1) ;// Delay 1ms
      digitalWrite (buzzer, LOW) ;// do not send voice
      delay (1) ;// delay ms
    }
    for (i = 0; i <100; i++) // Wen Qie out another frequency sound
    {
      digitalWrite (buzzer, HIGH) ;// send voice
      delay (2) ;// delay 2ms
      digitalWrite (buzzer, LOW) ;// do not send voice
      delay (2) ;// delay 2ms
    }
  }
}

.

Advertisements

One thought on “Buzzin’”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s