btdat2506

Buzzer Code

Oct 18th, 2021
863
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int buzzer = 5, button1 = 3;
  2.  
  3. void setup()
  4. {
  5.   pinMode(buzzer, OUTPUT);
  6.   pinMode(button1, INPUT);
  7. }
  8.  
  9. void loop()
  10. {
  11.   int button1_state = digitalRead(button1);
  12.     if (button1_state == LOW)
  13.     {
  14.       digitalWrite(buzzer, LOW);
  15.     }
  16.     else
  17.     {
  18.       digitalWrite(buzzer, HIGH);
  19.     }
  20.  
  21. }
RAW Paste Data