Nado Hollow
Published © MIT

Light control with clock

Control your home lights when it's ON or OFF using 1Sheeld.

BeginnerFull instructions provided8,285
Light control with clock

Things used in this project

Story

Read more

Schematics

Light control with clock Circuit

you only need one relay for each lamp.

Code

Untitled file

Arduino
/*

Clock Shield Example

This example shows an application on 1Sheeld's clock shield.

By using this example, you can send an SMS to a friend on his
birthday and update your status on Facebook when the phone's
time reaches a certain time you specify.

OPTIONAL:
To reduce the library compiled size and limit its memory usage, you
can specify which shields you want to include in your sketch by
defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define. 

*/

#define CUSTOM_SETTINGS
#define INCLUDE_CLOCK_SHIELD
#define INCLUDE_SMS_SHIELD
#define INCLUDE_FACEBOOK_SHIELD

/* Include 1Sheeld library. */
#include <OneSheeld.h>

/* Define some variables for the date and time. */
int hour, minute, second, day, month, year;
int relayPin = 13;

void setup()
{
  /* Start communication. */
  OneSheeld.begin();
  /* Start the clock shield. */
  Clock.queryDateAndTime();
  pinMode(relayPin,OUTPUT);
  digitalWrite(relayPin,LOW);
}

void loop() 
{
  /* Always get the date and time. */
  hour = Clock.getHours();
  minute = Clock.getMinutes();
  second = Clock.getSeconds();
  day = Clock.getDay();
  month = Clock.getMonth();
  year = Clock.getYear();
  
  /* If the date is my friends's birthday date send me 
     SMS at 3 pm that day and post on Facebook. */
  if(hour == 18 && minute == 18 && second == 30 && day == 10 && month == 9 && year == 2015)
  {
    digitalWrite(relayPin,HIGH);
  }
} 

Light control with clock Code

Change the time in this line of code if(hour == 18 && minute == 18 && second == 30 && day == 10 && month == 9 && year == 2015) you can make multiple if conditions for trigger events also you can have more than "relaypin"

Credits

Nado Hollow

Nado Hollow

2 projects • 4 followers

Comments