Hi there.
I'm currently a newbie to C++ and the Arduino, however i have a strong electronics background.
I've been working on a remote vehicle ignition for the past week now, and have had a PCB printed and everything physically has been implemented and pieced together minus the cell/gsm shield/
Basically, i have an arduino UNO R3, and two relays with transisters. one relay closes the contact for the vehicle to be "ON" and the second relay is to close the contact for the car's ignition.
Then i have an input that only goes HIGH when the vehicles alternator is running, thus, the car has started. When this pin is LOW, it means the car is not running.
What i've been told i need is a state machine, and as i'm new to C++, i have no idea how to piece this together.
I've done all the basic arduino tutorials, and can do very basic code. But nothing like a state machine.
What i need is this:
The arduino gets a serial command > fires the "ON" relay > Waits 5 seconds for the fuel pump to prime> then checks to see alternatorPin's state, if the state is LOW, the ignition relay is fired until the alternatorPin goes HIGH, once the alternatorPin goes HIGH, the ignition relay shuts off.
Then the code waits 10 minutes, after ten minutes the code restarts, waiting for another serial input.
I've put it like this:
State0: onPin = off, ignitionPin = off, alternatorPin = LOW.
Upon recival of serial command, go to state 1.
State1: onPin = on, ignitionPin = off, alternatorPin = LOW.
after 5 seconds go to state 2.
State2: onPin = on, ignitionPin = on, alternatorPin = LOW.
once alternatorPin becomes HIGH, go to state 3, if alternator pin is alrady HIGH, go to state0 (in case if someone floods the serial)
State3: onPin = on, ignitionPin = off, alternatorPin = HIGH.
once 10 minutes has elapsed go to state 0
This seems fairly simple, and i'm definetly willing to pay money in whichever way suits you, and your name would be included in the code.
Regards, Matt.