Difference between revisions of "Blog 11"
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
== Clock based On/off system == |
== Clock based On/off system == |
||
In this post I am going to work with crontab. What I am going to show is how you can make it possible to turn a light on or off on special times. |
|||
I |
I made this as some anti-criminal technique. So, that when I am away the lights are still on at night or day in the house. With that the house doesn't look like a house that has nobody in it. |
||
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. |
For this system I am of course going to try if it works 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. |
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 |
I already made a lamp go on and off in [[blog 02]]. So I am going to use that same way for turning on and off the lamp. |
||
Working with crontab has to all be done manually: |
|||
crontab -e |
crontab -e |
||
has to be done to open |
has to be done to open crontab for editing |
||
and have to put this in to make it work: |
|||
I then have to put this in to make it work to turn the light on at 13:19 and turn the light off at 13:20: |
|||
# mm hh dom mon dow command |
# mm hh dom mon dow command |
||
Line 25: | Line 26: | ||
To read a certain part: |
To read a certain part: |
||
crontab -l |grep bin/gpio |
crontab -l |grep bin/gpio |
||
( |
( With -v you can also let the other parts without bin/gpio appearing. |
||
For the people who don't understand: |
For the people who don't understand: |
||
Line 43: | Line 44: | ||
( 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.) |
( 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.) |
||
[[File:DSC05964.JPG|300px|thumb|none|]] |
|||
== manual Display Alarm == |
== manual Display Alarm == |
Latest revision as of 11:27, 26 October 2015
CHARLEY BETA!
Clock based On/off system
In this post I am going to work with crontab. What I am going to show is how you can make it possible to turn a light on or off on special times. I made this as some anti-criminal technique. So, that when I am away the lights are still on at night or day in the house. With that the house doesn't look like a house that has nobody in it.
For this system I am of course going to try if it works 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 way for turning on and off the lamp.
Working with crontab has to all be done manually:
crontab -e
has to be done to open crontab for editing
I then have to put this in to make it work to turn the light on at 13:19 and turn the light off at 13:20:
# 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 let the other parts without 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.)