Difference between revisions of "Buzzer Alarm"

From Microduino Wiki
Jump to: navigation, search
(Created page with "{| style="width: 800px;" |- | ==Purpose== This coure will show you the way to use Microduino buzzer to play music. ==Equipment== *'''Microduino-CoreUSB''' *'''Microdu...")
 
Line 4: Line 4:
 
==Purpose==
 
==Purpose==
  
This coure will show you the way to use Microduino buzzer to play music.  
+
This course will show you how to use Microduino buzzer to play simple songs.  
  
 
==Equipment==
 
==Equipment==
Line 12: Line 12:
  
 
*Other Hardware Equipment  
 
*Other Hardware Equipment  
**USB cable   One
+
**1x USB cable
  
 
==Buzzer Description==
 
==Buzzer Description==
Buzzer includes active buzzer and passive buzzer. Active buzzer has polarity like LED diode, whose long pin connects to VCC and the short pin to GND. With that connection, active buzzer can make continous sound. While the passive buzzer has no polarity. With three pins consisting of two power pins and an audio input pin, the passive buzzer can only make sound in audio output circuit. In this experiment, we adopt passive buzzer.   
+
Buzzer includes active buzzer and passive buzzer. Active buzzer has polarity like LED diodes, whose long pin connects to VCC and the short pin to GND. With that connection, active buzzer can make continous sounds. The passive buzzer has no polarity. With three pins consisting of two power pins and an audio input pin, the passive buzzer can only make sound in audio output circuit. In this experiment, we will use a passive buzzer.   
  
 
==Program==
 
==Program==
Line 50: Line 50:
  
 
*Function description  
 
*Function description  
The music coming from Arduino board is controlled by tone(). The change of the function can change the rythem of the music. The code includes two forms—tone(pin, frequency, duration) and tone(pin, frequency).  
+
The music coming from Arduino board is controlled by tone(). The change of the function can change the rhythm of the music. The code includes two forms—tone(pin, frequency, duration) and tone(pin, frequency). <br>
● In the first function, “pin” represents the pin that connects a loudspeaker.
+
● In the first function, “pin” represents the pin that connects to a loud speaker.<br>
● If using the sencond function, then you alos need noTone() to ccontrol the music.   
+
● If using the sencond function, then you also need noTone() to control the music.   
  
 
==Debugging==
 
==Debugging==
Line 70: Line 70:
 
==Result==
 
==Result==
  
You can use buzzer to play music.
+
You can use the buzzer to play music.

Revision as of 10:33, 6 September 2015

Purpose

This course will show you how to use Microduino buzzer to play simple songs.

Equipment

  • Other Hardware Equipment
    • 1x USB cable

Buzzer Description

Buzzer includes active buzzer and passive buzzer. Active buzzer has polarity like LED diodes, whose long pin connects to VCC and the short pin to GND. With that connection, active buzzer can make continous sounds. The passive buzzer has no polarity. With three pins consisting of two power pins and an audio input pin, the passive buzzer can only make sound in audio output circuit. In this experiment, we will use a passive buzzer.

Program

  • Program code
int song[] ={
    262,262,294,262,349,330,
    262,262,294,262,392,349,
    262,262,523,440,349,330,294,
    494,494,440,349,392,349
};
  
int noteDurations[] = { 
  4,4,2,2,2,1,
  4,4,2,2,2,1,
  4,4,2,2,2,2,2,
  4,4,2,2,2,1
};

void setup() {
  for (int thisNote = 0; thisNote<25;thisNote++)
  {
    int noteDuration = 1000/noteDurations[thisNote];
    tone(8, song[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration *1.30;
    delay(pauseBetweenNotes);
    noTone(8);
  }
}
void loop() {
  setup();
}
  • Function description

The music coming from Arduino board is controlled by tone(). The change of the function can change the rhythm of the music. The code includes two forms—tone(pin, frequency, duration) and tone(pin, frequency).
● In the first function, “pin” represents the pin that connects to a loud speaker.
● If using the sencond function, then you also need noTone() to control the music.

Debugging

Step 1: Insert Microduino buzzer to D8 pin of Microduino-Sensorhub.

MicroduinoBuzzerSensor.png

Step 2: Connect your PC with USB cable, download the code and program it to Microduino-CoreUSB.

MicroduinoBuzzerSensor1.png

Step 3: Power on and you’ll hear the music.

MicroduinoBuzzerSensor2.png

Result

You can use the buzzer to play music.