Arduino Beginner Tutorial 2: Buzzer

by TheMaker09 in Circuits > Arduino

272 Views, 1 Favorites, 0 Comments

Arduino Beginner Tutorial 2: Buzzer

F97UF7ZKV83PKWS.jpeg

You will make an Arduino project that makes sound. If you have not looked at my first project the Arduino blinking led project I recommend checking that out if you are a complete beginner.

Supplies


Supplies

1x Arduino Uno (any Arduino will work just this is what I use)

2x male to male jumper wires

1x breadboard (any size will do)

1x piezo buzzer

Software

You will need the Arduino software. Here is a link to it. Software | Arduino

Connect Components

PA262047.JPG
PA262045.JPG

plug the piezo buzzer into the breadboard (remember to make sure the two pins are in different rows.)

Then connect the positive side (it is usually labeled on the buzzer but if not it is again the side with the longer terminal) to Arduino pin 5 with one of the jumper wires. Then connect the negative side to a ground pin on the Arduino with the other jumper wire.

Connect Arduino to Computer

2021-10-26.png

Open the Arduino IDE and plugin your Arduino. Go to tools then boards and click Arduino Uno. Then go to tools port and click the port that it shows. Now you are connected.

Upload Code

2021-10-26 (1).png

Cope and paste this code into the sketch after deleting everything that automatically comes up.


const int buzpin = 5;

void setup() {
  pinMode(buzpin, OUTPUT);

}

void loop() {
  tone(buzpin, 300);
  delay(1000);
  noTone(buzpin);
  delay(1000);
  tone(buzpin, 900);
  delay(1000);
  noTone(buzpin);
  delay(1000);
  

}

Now click the upload button or ctrl + u.

Done

Now it should be making a high the low sound. Play with it. add more tone no tone. To change the pitch change the value in the "tone" function. Study the code try to figure it out If you can't figure it out, tell me in the comments and I will edit and explain it. If this is too hard for the beginner to understand please tell me so I can explain better. watch the video so you can see what it should do.

Downloads