In this lesson, you will learn how to generate a sound with an active buzzer.
Component Required:
(1) x Sintron Uno R3
(1) x Active buzzer
(2) x F-M wires (Female to Male DuPont wires)
(1) x Sintron Uno R3
(1) x Active buzzer
(2) x F-M wires (Female to Male DuPont wires)
Component Introduction
BUZZER:
Electronic buzzers are DC-powered and equipped with an integrated circuit. They are widely used in computers, printers, photocopiers, alarms, electronic toys, automotive electronic devices, telephones, timers and other electronic products for voice devices. Buzzers can be categorized as active and passive ones. Turn the pins of two buzzers face up. The one with a green circuit board is a passive buzzer, while the other enclosed with a black tape is an active one.
The difference between the two is that an active buzzer has a built-in oscillating
source, so it will generate a sound when electrified. A passive buzzer does not have such a source so it will not tweet if DC signals are used; instead, you need to use square waves whose frequency is between 2K and 5K to drive it. The active buzzer is often more expensive than the passive one because of multiple built-in oscillating
circuits.
code ( please copy and upload sketch to arduino board )
remember to remove sticker while using.
BUZZER:
Electronic buzzers are DC-powered and equipped with an integrated circuit. They are widely used in computers, printers, photocopiers, alarms, electronic toys, automotive electronic devices, telephones, timers and other electronic products for voice devices. Buzzers can be categorized as active and passive ones. Turn the pins of two buzzers face up. The one with a green circuit board is a passive buzzer, while the other enclosed with a black tape is an active one.
The difference between the two is that an active buzzer has a built-in oscillating
source, so it will generate a sound when electrified. A passive buzzer does not have such a source so it will not tweet if DC signals are used; instead, you need to use square waves whose frequency is between 2K and 5K to drive it. The active buzzer is often more expensive than the passive one because of multiple built-in oscillating
circuits.
Schematic
Wiring diagram
Everything between /* and */ or after // is a block comment; it explains what the sketch is for.
//by Sintron
//2017.03.20
const int buzzer = 12; //buzzer to arduino pin 12
void setup(){
pinMode(buzzer, OUTPUT); // Set buzzer - pin 12 as an output
}
void loop(){
tone(buzzer, 1000); // Send 1KHz sound signal...
delay(1000); // ...for 1 sec
noTone(buzzer); // Stop sound...
delay(1000); // ...for 1sec
}
0 意見:
張貼留言