Piezo buzzer controlled by push button using Arduino - Wired Connection


Circuit Diagram:

Required Components:

Arduino Nano/Uno - 1 nos
Piezo Buzzer - 1 nos
Push button - 1 nos
Battery - 1 nos
330k resister - 1 nos
10k resister  - 1 nos

Program Code:

 #define buzzer 8
#define buttonpin 7

void setup(){
  pinMode(buttonpin,INPUT);
}


void loop(){
  if(digitalRead(buttonpin)==HIGH){
    tone(buzzer,3500);
  }
  else{
    noTone(buzzer);
  }
}

Comments

Popular posts from this blog

Servo motor controlled by Joystick using Arduino & Transceiver - Wireles...

DC motor controlled by Joystick using Arduino & L298N Motor driver - Wireless Connection

DC motor controlled by Gyro MPU 6050 using Arduino & L298N Motor driver - Wired Connection