Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int buzzerPin = 2;
- const int defaultDelay = 250;
- int currentDelay = defaultDelay;
- void setup () {
- Serial.begin(115200);
- pinMode(buzzerPin, OUTPUT);
- }
- void loop () {
- digitalWrite(buzzerPin, LOW);
- delay(currentDelay);
- digitalWrite(buzzerPin, HIGH);
- Serial.println(currentDelay);
- delay(currentDelay);
- if (currentDelay == 0){ // Si es igual a cero, ha acabado y por lo tanto "explota"
- currentDelay = defaultDelay;
- Serial.println("Explota");
- digitalWrite(buzzerPin, HIGH);
- delay(1000);
- digitalWrite(buzzerPin, LOW);
- delay(2500);
- Serial.println("\nReinicia"); // El \n sirve para que deje una linea en blanco
- } else {
- currentDelay -= 5;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement