Friday, April 13, 2012

Controlling a buzzer with a push button using arduino

Here is a small example of how we can control a buzzer using a push button using the arduino uno. This is just an small extension to the example of button available at ardunio site http://arduino.cc/it/Tutorial/Button.

We connect one side of the push button to 5V by connecting one of the two legs to the 5V pin on the board.

The other side of the push button is connected to the ground using a 1K ohm resistor.

The same end of the resistor which connected to ground is also connected to the digital I/O pin 2

The digital I/O pin 3 is connected to the positive leg of the buzzer and the negative leg is connected to the ground.

The following breadboard and schematic figures show the connections.

Program:

The pin2 acts a digital input.

The pin3 acts as digital output.

Whenever the push button gets pressed a high is sent to pin2 which is read as as input and whenever a high is read on pin2 a high is sent on pin3 which turns the buzzer on. Hence making the buzzer beep whenever the push button is pressed.

5 comments:

  1. your button is not configured correctly. thanks anyway, I figured it out!

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. What is the problem you are facing ?

      Delete
    3. Your wire from the arduino port 2 needs to be connected to the button not the resistor.

      Delete

Follow by Email