Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Connect the positive side of the buzzer to pin 3 on the Arduino using a breadboard,
- then connect the negative side of the piezo to a 1k resistor. Finally, connect the other side
- of the 1k resistor to one of the ground (GND) pins on the Arduino.
- */
- #define buzzerPin 3
- #define minFreq 30
- #define maxFreq 10000
- void setup() {
- }
- void loop() {
- // siren goes up
- for (int i = minFreq; i <= maxFreq; i++) {
- tone(buzzerPin, i);
- delay(1);
- }
- // siren goes down
- for (int i = maxFreq; i >= minFreq; i--) {
- tone(buzzerPin, i);
- delay(1);
- }
- noTone(buzzerPin);
- }
Advertisement
Add Comment
Please, Sign In to add comment