I am trying to make a controller for a transmission shifting mechanism. What I am trying to do is have a push button trigger a timed 5v output to a relay which will open a solenoid, moving the actuator. My question is... which function would be easiest to trigger for a certain length of time (milliseconds)? I have seen the scheduler, fuse burn, and others but I dont think they would work.. I was thinking maybe the delay function? I am a totally noob at this but I want to learn, so if you could point me in the right direction that would be great!
Suppose millis return 27. You store that in Upstart. That takes a couple of machine instructions to perform, granted, but each machine instruction executes in 62.5 nano-seconds, so it's not a LOT of time.
Then, you immediately test if Upstart + interval is equal to the value returned by millis.
Unless you have changed out the crystal on your Arduino, it does not seem like that 1/4 of a second has elapsed while the value was stored, millis was called again, and the if statement evaluated.
If you got one of those 4Hz crystals, maybe...
Since the Arduino comes with either a 8,000,000 or 16,000,000 Hz crystal, it seems unlikely that the if condition will ever evaluate to true.
Okay so now I have the issue that when I hold the button down it holds the relay/solenoid open. I'm fairly sure that it is because the delay is starting after the button is closed not as soon as it opens.. which doesnt make much sense to me.
Do you have external pull-up or pull-down resistors on the switches? You are not enabling the internal pull-ups, so external ones are required.
if (Downstart + Downinterval == millis() && DownsolState == HIGH )
The value returned by millis should never appear to one side of the == operator. The value returned by millis should never be used in an addition construct.