Hi guys, if any of you have been on the project guidence section within the last week, you might have seen my remote vehicle ignition thread.
I'm now upto the codeing part of the project, and having never coded anything other than basic HTML, it's quite daunting at first.
I'm quite stuck, basically this is how the project pans out.
arduino with cell shield (havn't actually got the cell shield yet, so i'm working off of serial for now)
i want it working like this:
Arduino recieves serial command> fires the ON relay at pin 12> wait's 5 secs for fuelpump/glow plugs> checks input pin 4's state, if low, fires igniton pin 11>once input pin 4's state goes high, it turns off ignition pin 11. >if brakeswitch pin 3 is low nothing happens until 15 minutes has past, then code restarts, when brakeswitch pin 3 goes high, it restarts the code thus the ON pin goes low and is now waiting for serial input to tell it to start again.
Basically, upon serial input the car starts, and waits 15 minutes or for the brake switch to be depressed, whichever comes first. so the user gets to the car before the 15 minutes is up, and puts the key in and switches to the on position, thus closing the cars normal relays. then he/she presses the brake pedal, thus the arduino code loops back to the start and is ready for another serial input.
Is this at all possible? this is what i've come up with so far, and it doesn't work properly ![]()
int ignitionPin = 12;
int onPin = 11;
int ledPin = 13;
int brakePin = 3;
int alternatorPin = 4;
int usbnumber = 0;
void setup() {
pinMode(onPin, OUTPUT);
pinMode(ignitionPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(4,INPUT);
pinMode(3,INPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
usbnumber = Serial.read();
}
if (usbnumber > 0) {
digitalWrite(onPin, HIGH);
delay(5000);
if (digitalRead(alternatorPin)==LOW)
{digitalWrite(ignitionPin,HIGH);}
else
{digitalWrite(ignitionPin,LOW);}
if (digitalRead(brakePin)==LOW)
{digitalWrite(ledPin,HIGH);}
else
{digitalWrite(13,LOW);}
delay(1000);
usbnumber = 0;
}
}
cheers, Matt.