Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
Razbot
Published

Arduino Alarm Clock Project

Make an alarm clock that will only stop once the light is on and the button is pressed using an Arduino Nano.

Full instructions provided5,212
Arduino Alarm Clock Project

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
or any arduino
×1
ISD1829
https://www.allelectronics.com/mas_assets/media/allelectronics2018/spec/ME-63.pdf
×1
Grove - RTC
Seeed Studio Grove - RTC
any RTC module
×1
LDR, 5 Mohm
LDR, 5 Mohm
any LDR
×1
Pushbutton Switch, Push On-Push Off
Pushbutton Switch, Push On-Push Off
Any push
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Wake up Code

Arduino
using DS3231 library
#include <DS3231.h>
#define Hour 7    //define hour to wake up
#define minute 0 //define minute to wake up
// Init the DS3231 using the hardware interface
DS3231  rtc(SDA, SCL);   //set up RTC module
int Shout = 7;          //this is connected to the ISD module
int Butt = 6;           //this is the button
int Light = A0;         //LDR
bool Stop;             //Bool to stop screaming
long Read;             //to read LDR analog value
Time  t;               //from the Library

void setup()
{
  Serial.begin(115200);   //just for debug. not important
  pinMode(Shout,OUTPUT);  //define inputs and outputs
  pinMode(Butt,INPUT);
  rtc.begin();            //from library
  Stop = false;           //Scream at mE!!! (not yet)
}

void loop()
{
  t = rtc.getTime();     //get the time from RTC module
  if(rtc.getDOWStr()!= "FRIDAY" &&rtc.getDOWStr()!= "SATURSDAY")//unless its the weekend!
  {
    if((t.hour)== Hour && (t.min) == minute )   //when Time as come...
    {
      while(Stop==false)     //as long as the Bool is false (starting poin is false)
      {
         Read = analogRead(Light);  //read analog value
         digitalWrite(Shout,HIGH);  //the routine to oparate scream flow
         delay(20);
         digitalWrite(Shout,LOW);
        if((t.hour)== Hour && (t.min) == (minute+20))//if it lastad for more than 20 minutes 
          Stop=true;                              //Stop screaming at me!!
        if(digitalRead(Butt)==1 && Read >=905)//if the button is Pressed AND the light is ON!
          Stop=true;                           // STOP THIS MADDNESSSSSS
      } 
      delay(80000);            
      Stop=false;                         //get ready to start again tomorrow!
    }
  
  
  
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");
  // Send time
  Serial.println(rtc.getTimeStr());

  
  // Wait one second before repeating :)
  delay (1000);
  /*   SET this to change time!  do this if u didn't set the RTC time
  if(digitalRead(Butt))
  {
     rtc.setDOW(MONDAY);     // Set Day-of-Week to MONDAY
  rtc.setTime(19,35, 0);     // Set the time to 19:35:00 (24hr format)
  rtc.setDate(8, 4, 2019);   // Set the date to april 8, 2019
  }
  */
  
  }
}

Credits

Razbot

Razbot

4 projects • 0 followers

Comments