Difference between revisions of "Sensor-Buzzer"
From Microduino Wiki
(Created page with "{{Language|Microduino-Buzzer }} {| style="width: 800px;" |- | 400px|thumb|right| Microduino-Buzzer Microduino-Buzzer is passive just like a ma...") |
|||
Line 1: | Line 1: | ||
− | {{Language|Microduino-Buzzer }} | + | {{Language|Microduino-Buzzer}} |
{| style="width: 800px;" | {| style="width: 800px;" | ||
|- | |- |
Revision as of 07:48, 30 October 2015
Language: | English • 中文 |
---|
Microduino-Buzzer is passive just like a magnetic speaker. It needs voltage with different frequency and thus can make sound accordingly. The sound becomes louder when the frequency gets higher.
ContentsFeature
Specification
Document
DevelopmentIt can be used to make various kinds of sound through the buzzer. Application
#define buzzer_pin 6
void setup()
{
pinMode(buzzer_pin,OUTPUT);
}
void loop()
{
for(int i=200;i<=800;i++) //Increase the frequency from 200HZ to 800HZ circularly.
{
tone(buzzer_pin,i); //Output frequency in the port.
delay(5); //The frequency lasts for 5ms.
}
delay(1000); //The highest frequency lasts for 1s.
for(int i=800;i>=200;i--)
{
tone(buzzer_pin,i);
delay(10); //The frequency lasts 10ms.
}
}
PurchaseHistoryImage
|