Hi guys i'm completely new to all this, so bare with me.
I've just picket up a new uno board which i'm hoping to use for a small project on my car boot.
I've fitted a boot popper solenoid and uprated gas struts so it faithfully opens fully. However closing it again isn't easy. You know when it sort of latches but not propperly and you've got to press the open button again to slam it....
I've decided to set up a switch to detect when the boot is in that 'state', and fire the solenoid again. However the boot must pass through that 'state' to close properly which will result in the solenoid firing and not shutting properly ect.
So I need a program which will not fire the solenoid until the boot has been in that state for more than 2 seconds. The board will have a single 12v input from the switch, and have an output capable of triggering a relay. It will be permanently powered by 12v from the car.
Could anyone point me in the right direction of a program which would achieve this? I'm completely new to writing a program in this way, so any help is greatly appreciated.
Could anyone point me in the right direction of a program which would achieve this?
You need to detect the state of interest. When that state (not fully closed) occurs, use millis() to record when it first happened.
You'll also need to detect when that state ends (fully closed is entered), if it does. If it does, clear the start time.
Periodically, check the time, and, if the state is not fully closed, there is a start time noted, and the time between then and now (use millis() again) is greater than some interval (you mentioned two seconds; that seems awfully long to me), pop the trunk again.
Boot? A boot is something you wear to keep your feet dry.
However I've already got the logic circuit sorted for the switch, so there will only be a single 12v input when it's in the 'not properly closed state'.
Does that mean the program can be simplified to the extent that it detects the 12v input, waits for 2 seconds, then has an output?
I am completely new to this, so this is still way above my head :~
Thanks, Stuart
However the boot must pass through that 'state' to close properly
However I've already got the logic circuit sorted for the switch, so there will only be a single 12v input when it's in the 'not properly closed state'.
These seem to conflict with each other. If the switch goes on then off, you simply need to detect each transition. The transition to On results in storing a time. The transition to Off results in clearing that time.
Periodically, you determine, if there is a "then" defined, whether the interval between now and then exceeds your desired interval. If so, the boot is on the wrong foot. I mean stuck in the not-quite-closed position.