Devices & Components
Arduino Nano
Jumper wires (generic)
Buzzer, Piezo
Breadboard (generic)
Software & Tools
Arduino IDE
Project description
Code
Code
arduino
Copy and paste this code into the arduino ide or download and unzip it.
1// words in the double slash are not part of the code 2 3#define buzzer 2 //change to any output pin (not analog inputs) 4 5void setup() { //run this code once 6 pinMode(buzzer, OUTPUT); //tell arduino the buzzer is an output device 7} 8 9void loop(){ //loop forever... 10 11 for(int i=0; i<255; i++) { //do this 255 times 12 analogWrite(buzzer, i); //raise the voltage sent out of the pin by 1 13 delay(10); //wait 10 milliseconds to repeat 14 } 15 16 for(int i=255; i>0; i--) { // do this 255 times 17 analogWrite(buzzer, i); //lower the voltage sent out of the pin by 1 18 delay(10); //wait 10 milliseconds to repeat 19 20 } 21}
Downloadable files
Wiring diagram
Use this to set up the project
Wiring diagram

Wiring diagram
Use this to set up the project
Wiring diagram

Comments
Only logged in users can leave comments