arduino_uno_guy
Published © GPL3+

The Simplest Alarm in the World Using Active Buzzer

This project is for beginners and is great for pranks.

BeginnerFull instructions provided26,602
The Simplest Alarm in the World Using Active Buzzer

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Buzzer, Piezo
Buzzer, Piezo
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE

Story

Read more

Schematics

Wiring diagram

Use this to set up the project

Code

Code

Arduino
Copy and paste this code into the arduino ide or download and unzip it.
// words in the double slash are not part of the code

#define buzzer 2 //change to any output pin (not analog inputs) 

void setup() { //run this code once
  pinMode(buzzer, OUTPUT); //tell arduino the buzzer is an output device
}

void loop(){ //loop forever...
  
  for(int i=0; i<255; i++) { //do this 255 times
    analogWrite(buzzer, i); //raise the voltage sent out of the pin by 1
    delay(10); //wait 10 milliseconds to repeat 
  }

  for(int i=255; i>0; i--) { // do this 255 times
    analogWrite(buzzer, i); //lower the voltage sent out of the pin by 1
    delay(10); //wait 10 milliseconds to repeat
    
  }
}

Credits

arduino_uno_guy
1 project • 8 followers

Comments