/**
Arduino Digital Alarm Clock
Copyright (C) 2020, Uri Shaked.
Released under the MIT License.
*/
#include <SevSeg.h>
#include "Button.h"
#include "AlarmTone.h"
#include "Clock.h"
#include "config.h"
// Include the necessary libraries
#include <Arduino.h>
// Define the pin for the button and LED
#define BUTTON_PIN 2
#define LED_PIN 13
// Define the state of the LED
bool ledState = false;
// Define the previous state of the button
bool prevButtonState = false;
// Define the current state of the button
bool currButtonState = false;
// Define the time interval for the LED to be on and off
#define LED_ON_TIME 1000 // 1 second
#define LED_OFF_TIME 1000 // 1 second
// Define the time interval for the LED to be on for 5 seconds
#define LED_ON_TIME_5S 5000 // 5 seconds
// Define the variable to keep track of time
unsigned long previousMillis = 0;
void setup() {
// Set the button pin as input
pinMode(BUTTON_PIN, INPUT);
// Set the LED pin as output
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// Read the current state of the button
currButtonState = digitalRead(BUTTON_PIN);
// Check if the button is pressed
if (currButtonState == HIGH && prevButtonState == LOW) {
// Turn on the LED for 1 second
digitalWrite(LED_PIN, HIGH);
delay(LED_ON_TIME);
// Turn off the LED for 1 second
digitalWrite(LED_PIN, LOW);
delay(LED_OFF_TIME);
// Turn on the LED for 1 second
digitalWrite(LED_PIN, HIGH);
delay(LED_ON_TIME);
// Turn off the LED for 1 second
digitalWrite(LED_PIN, LOW);
delay(LED_OFF_TIME);
// Turn on the LED for 1 second
digitalWrite(LED_PIN, HIGH);
delay(LED_ON_TIME);
// Turn off the LED for 1 second
digitalWrite(LED_PIN, LOW);
delay(LED_OFF_TIME);
// Turn on the LED for 1 second
digitalWrite(LED_PIN, HIGH);
delay(LED_ON_TIME);
// Turn off the LED for 1 second
digitalWrite(LED_PIN, LOW);
delay(LED_OFF_TIME);
// Turn on the LED for 5 seconds
digitalWrite(LED_PIN, HIGH);
delay(LED_ON_TIME_5S);
// Turn off the LED
digitalWrite(LED_PIN, LOW);
}
// Update the previous state of the button
prevButtonState = currButtonState;
}
// Code sourced from: https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button