Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int ledPin = 13; // the number of the LED pin
- int ledState = LOW; // ledState used to set the LED
- unsigned long previousMillis = 0; // will store last time LED was updated
- int buzzer = 8;
- const long interval = 1000; // interval at which to blink (milliseconds)
- unsigned long currentMillis ;
- void setup() {
- // set the digital pin as output:
- pinMode(ledPin, OUTPUT);
- pinMode(buzzer,OUTPUT);
- }
- void loop()
- {
- currentMillis = millis();
- if(currentMillis - previousMillis >= 1200) {
- previousMillis = currentMillis;
- if (ledState == LOW){
- ledState = HIGH;
- tone(buzzer,3300,50);
- }
- else{
- noTone(buzzer);
- ledState = LOW;
- }
- // set the LED with the ledState of the variable:
- digitalWrite(ledPin, ledState);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement