Advertisement
pippero

Untitled

Jan 6th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1.  
  2. const int ledPin = 13; // the number of the LED pin
  3. int ledState = LOW; // ledState used to set the LED
  4. unsigned long previousMillis = 0; // will store last time LED was updated
  5. int buzzer = 8;
  6. const long interval = 1000; // interval at which to blink (milliseconds)
  7. unsigned long currentMillis ;
  8. void setup() {
  9. // set the digital pin as output:
  10. pinMode(ledPin, OUTPUT);
  11. pinMode(buzzer,OUTPUT);
  12. }
  13.  
  14. void loop()
  15. {
  16. currentMillis = millis();
  17. if(currentMillis - previousMillis >= 1200) {
  18. previousMillis = currentMillis;
  19.  
  20. if (ledState == LOW){
  21.  
  22. ledState = HIGH;
  23. tone(buzzer,3300,50);
  24. }
  25. else{
  26. noTone(buzzer);
  27. ledState = LOW;
  28. }
  29. // set the LED with the ledState of the variable:
  30. digitalWrite(ledPin, ledState);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement