I have a project that I am in the stage of thinking about the way it all fits together.
What is the project?
This project is to automate shutting of the garage door. (What typically happens::: me or my wife gets home after work, use a remote to open the garage, go in, and go inside the house. We sometimes forget to close the garage). So from this, we have a Garage open all night. Not a good thing.
Ok, to the coding thing.
For sure I will need to write some lengthy code to make it all work.
So to make the concept clear in my head I produced a logic diagram of how I expect it to work.
I however am no pro c++ coder, however I do code a lot in .ksh for my work. So all the
logic I have used to construct the logic view is all based on the structure of .ksh
I have read a lot of the items here on this forum, and am missing some concepts and ways of logically joining things.
so my question is in the form of the way you call routines in code bundles.
I am looking for suggestions and ideas to help me on the way. All appreciated.
SHED LOGIC BELOW
Items
Shed magnetic door switch
Shed movement sensor,(one that an alarm will use, so just read the reed switch)
Shed light sensor
Shed buzzer
House buzzer
remote to shut the shed door
Warning LED (in the house)
Bypass switch
[Main Loop Start]
[1]If bypass switch is on
Then
{
read time
if time > 8:00am and < 6:00pm
then
{
turn warning led off
}
if time > 6:00pm and < 8:am
then
{
turn warning led on
}
exit (back to the start of main loop)
}
[2]read door switch
if door switch = closed
then
{
read light sensor
if light Sensor = on
then
{
turn warning LED on
}
if Light sensor = off
then
{
turn warning led off
}
}
exit (back to the start of main loop)
[3]read time
if time > 8:00am and < 6:00pm
then
{
exit (back to the start of main loop)
}
[4]read time
if time > 6:00pm and < 8:am
then
{
read door switch
if door switch = open
then
{
read light sensor
if light sensor = on
then
{
Start a "timer loop"
{
read movement sensor
if movement sensor = on
then
{
re-set/re-start "timer loop" number to 0
}
read light sensor
if light sensor = off
then
{
exit (back to the start of main loop)
}
}
if "timer loop" = 10 mins
then
{
read movement sensor
if movement sensor = on
then
{
stop the buzzer in house and shed
exit (back to the start of main loop)
}
Start a buzzer in the House and Shed
Start a "timer loop2"
{
read door switch
if door switch = closed
then
{
stop the buzzer in house and shed
read the light switch
if the light switch is off
then
{
turn off the warning LED for shed light is on.
stop the shed and house buzzers
exit (back to the start of main loop)
}
turn on the warning LED for shed light is on.
exit (back to the start of main loop)
}
if the "timer loop2" = 10 seconds
then
{
stop the buzzer in house and shed
turn on the warning LED for shed light is on.
shut the shed door
exit (back to the start of main loop)
}
}
start a "timer loop3"
{
read movement sensor
if movement sensor = on
then
{
re-set/re-start "timer loop3" number to 0
}
}
if "timer loop3" = 10 mins
then
start "timer loop4"
{
start the shed buzzer
if "timer loop4" = 10 seconds
then
{
stop the shed buzzer
shut the shed door
}
exit (back to the start of main loop)
}
Main routine
[1]
[2]
[3]
[4]
So basically have all the callable code up top and call each routine as needed with tests.. if and else if needed.
For sure I will need to write some lengthy code to make it all work.
Why? Observe when the door becomes open. Observe when the door becomes closed. If that happens forget about the open. On each pass through loop(), see how long the door has been open. If more than some interval, close the door. Maybe 20 lines altogether.
Why do you need the LED and buzzer? Just shut the door.
For sure I will need to write some lengthy code to make it all work.
Why? Observe when the door becomes open. Observe when the door becomes closed. If that happens forget about the open. On each pass through loop(), see how long the door has been open. If more than some interval, close the door. Maybe 20 lines altogether.
Why do you need the LED and buzzer? Just shut the door.
Hi
Thanks for the reply.
I must say It should have been best if I stated my per-requisites.
There is some thought put into why a buzzer, (buzzer will not be loud, but enough to get your attention) and light., and also the time of day. {As a future project I will look at using the actual sunrise and sunset and add this to this rather than time}
##NB::In all cases, the time of the day is the first check. So if it falls in the time I do want the garage door shut, it should try to do so. Any other time whatever state the door or lights are in does not matter
Scenario's for this.
Scenario 1:
*I am home , it is late, the light is on, I am working in the garage, the garage door is open, I am in sight of the movement sensor, but have not moved enough to trigger it. #The garage and house Buzzer will go off, I quickly move a bit more than usual, (wave an arm..etc). the timer is re-set.
Scenario 2:
*it is late, I am in the garage, go in the house, shut the garage door and forget to turn the garage light off.
the garage door is closed but the garage light is on. a LED will turn on in the house, ( I will put it in a part of the house that I will cross it's path:: IE hallway)
Scenario 3:
*it is late, I am in the garage, go in the house, forget to shut the garage door and turn off the light #movement sensor check and timer, eventually the garage and house buzzer will go off, the LED light in the house will turn on
and the garage door will be shut
Scenario 4:
It is late, the garage door is open and the light is off
movement sensor check and timer, the garage buzzer will go off and the garage door will be shut
First and most important. Compared to so many newcomers here you have taken the trouble to write down the logic of what you need. Go to the head of the class.
Second, I'm inclined to agree with @PaulS. If you are new to the Arduino, start simple.
Is there any objection to closing the door during the day (even if it is not necessary?).
If you want the doors to stay open while you are in the garage it would be simple to have a switch that you press if the doors start to close when you don't want them.
you are working in the yard, or in the shed. not close enough to the sensor, but you want the door to stay open.
test if the shed door is open or the shed light is on. those would indicate you want the garage door to remain open.
at some point all the conditions are met to close, the buzzer alerts you that all the conditions are met, and will now close. giving you an opportunity to re-set things if you are outside and want to keep the door open.
if you take the dog for a walk, shed is closed, light is off, eclipse, senses night, closes door, you are locked out.
having a way to enter, a keypad or some such would be a good idea.
you could have a sequence
garage door opens, house door opens. timer is faster.
house door opens, garage door opens, shed door opens, timer is much-much longer
do you have a sensor for the car ?
house opens, garage opens, car sensor indicate car is moved. (going out)
.....shed door opens..... you are working on the car, long delay
I can't believe how complicated this has become. What if the garage door is open and the car has been pulled forward to give more working space in the garage ? Now you presumably don't want the door to close automatically or remotely.
How about a note on the door to the house "Have you closed the garage door and turned off the light ?"
UKHeliBob:
I can't believe how complicated this has become. What if the garage door is open and the car has been pulled forward to give more working space in the garage ? Now you presumably don't want the door to close automatically or remotely.
How about a note on the door to the house "Have you closed the garage door and turned off the light ?"
in keeping with using technology...how about an arduino with LCD that displays
"Have you closed the garage door and turned off the light ?"
we will end with an arduino heart here; but with a good 3d printer hearts will end to be easy to copy
maybe attach the wife to the door will let the board usable for a more complicated project
Sorry for the confusion on the use of the words Shed and Garage.. I have a Garage, however it is very large and I work in it like my shed.
I have corrected the scenarios .. as below with the word Garage.
Hi
Thanks for the reply.
I must say It should have been best if I stated my per-requisites.
There is some thought put into why a buzzer, (buzzer will not be loud, but enough to get your attention) and light., and also the time of day. {As a future project I will look at using the actual sunrise and sunset and add this to this rather than time}
##NB::In all cases, the time of the day is the first check. So if it falls in the time I do want the garage door shut, it should try to do so. Any other time whatever state the door or lights are in does not matter
Scenario's for this.
Scenario 1:
*I am home , it is late, the light is on, I am working in the garage, the garage door is open, I am in sight of the movement sensor, but have not moved enough to trigger it. #The garage and house Buzzer will go off, I quickly move a bit more than usual, (wave an arm..etc). the timer is re-set.
Scenario 2:
*it is late, I am in the garage, go in the house, shut the garage door and forget to turn the garage light off.
the garage door is closed but the garage light is on. a LED will turn on in the house, ( I will put it in a part of the house that I will cross it's path:: IE hallway)
Scenario 3:
*it is late, I am in the garage, go in the house, forget to shut the garage door and turn off the light #movement sensor check and timer, eventually the garage and house buzzer will go off, the LED light in the house will turn on
and the garage door will be shut
Scenario 4:
It is late, the garage door is open and the light is off
movement sensor check and timer, the garage buzzer will go off and the garage door will be shut
An additional thought.
As the Garage door will be not-monitored, a way of detecting that an obstacle will be hit by the door might be of value.
In my case, the garage door will swing down, ( some are the roller door style, mine is not).
I will have to think about a way of stopping the door from hitting anything, (for sure the door will stop and re-open if it is stopped. However) I expect there to be a dint in a car bonnet if there is one in the way.
Just some more code to think about for an addition to this one.
I might save this bit for another day.
Anyhow the reason I wrote this in the first place is to discuss the programming concepts for this..
Apart from that, I never expected this much interest in my little project.
Thank you for the feedback.
Robin2:
First and most important. Compared to so many newcomers here you have taken the trouble to write down the logic of what you need. Go to the head of the class.
Second, I'm inclined to agree with @PaulS. If you are new to the Arduino, start simple.
Is there any objection to closing the door during the day (even if it is not necessary?).
If you want the doors to stay open while you are in the garage it would be simple to have a switch that you press if the doors start to close when you don't want them.
...R
Hi and thanks for the reply.
I for sure am new to this system.
I however am familiar with programming micro-controllers, be them with hex coding only.
I will even state that I have designed, built and self coded my own computer, (be it only running in Hex, [gosh, 30 years ago]).
This style of system is new to me, but not difficult, However with any new concepts, questions will help speed any sticky points along the way of learning.
So here i am, asking many silly questions, and devouring your useful feedback.
there are many sensors for garage doors. you can hang a soft tube a few inches below the door. as it closes, the weight closes switches. if the tube touches anything the weight of the tube is transferred to the object and the switch activates.
there are some user sequences that could effect timing.
garage opens, house door opens, house door closes.
this would usually be someone arriving, entering the garage, then they house.
this would indicate a fast time-out before door closure.
house door opens, garage door opens, car sensor indicates car has left. fast count
house door opens first. start a long count.
before the door is to be closed a flash of the lights to indicate imminent closure.
if the button near your work station is activated, the garage door would remain open indefinitely.
until the house door is opened, that would re-set the timer.
you might want to consider starting with a wireless light. after the time-out the light goes on indicating the door is opened.
put it near where you think you would be, or use multiples. that way, you would see the timing and be able to note if that timing was going to work.