Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int led = 9;
- int buzzer = 10;
- int button = 11;
- bool isPressed;
- void setup() {
- pinMode(led, OUTPUT);
- pinMode(buzzer, OUTPUT);
- pinMode(button, INPUT);
- }
- void loop() {
- isPressed = digitalRead(button);
- if(isPressed == true){
- digitalWrite(led, HIGH);
- tone(buzzer, 400);
- delay(200);
- digitalWrite(led, LOW);
- noTone(buzzer);
- delay(200);
- }
- else{
- digitalWrite(led, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement