Blog 11

From BitWizard Wiki
Jump to navigation Jump to search

CHARLEY BETA!

Clock based On/off system

My new system I am going to make is a system that on special times turns light on or off. I want to use this as some anti-criminal system. So, that when I am away the lights are still on at night or day in the house. So the house doesn't look like a house that is asking for crackers or criminals.

For this system I am of course going to try it with shorter times otherwise I have to wait 8 hours for a lamp to get on or off.

So when I start the code I plan it 1 minute in the future.

I already made a lamp go on and off in blog 02. So I am going to use that same set-up for turning on and off the lamp.

Crontab is more manually

crontab -e 

has to be done to open and have to put this in to make it work:

#  mm hh dom mon dow command 
19 13 * * * /usr/local/bin/gpio write 3 1 
20 13 * * * /usr/local/bin/gpio write 3 0 

To read a certain part:

crontab -l |grep bin/gpio 

( with -v you can also the other parts with out bin/gpio appearing.

For the people who don't understand:

  • 1 (mm)Minute 0-59
  • 2 (hh)Hour 0-23 (0 = midnight)
  • 3 (dom)Day 1-31
  • 4 (mon)Month 1-12
  • 5 (dow)Weekday 0-6 (0 = Sunday)

So the text from my is now saying:

gpio write 3 1 at 13:19
gpio write 3 0 at 13:20

To manually change it in the command line:

( echo "#  mm hh dom mon dow command" ; echo '19 13 * * * /usr/local/bin/gpio write 3 1' ;  echo '20 13 * * * /usr/local/bin/gpio write 3 0' ) |  crontab 

( You can of course also use it as alarm clock, then you only have to change the command to the location of the audio file you want to play.)

manual Display Alarm