Start Remote Car

Hi!

I don't know where i post this...

I am Cesario Da Silva, i am portuguese
know a little english, very good spanish, and native portuguese.

So, i make and programing my own start remote in my car, with arduino uno r3 board, one own board with 5 relays and control remote transmiter and receiver. put photos if some one want see.
programing on Arduino IDE.

Thanks for God help me.

/*
Start Remote

Work with 4 channel transmiter rf and receiver
one board with 5 relays or more
Arduino Uno r3 or compatible

Created 15 Dec 2013
by Cesario Da Silva

The glory for God

*/

int r1 = 9; //Ignition
int r2 = 8; //Starter
int r3 = 7; //Acc (to headlights on and a/c or heater)
int r4 = 6; //Headlights
int r5 = 5; //Horn
int re1 = 0; //State of ignition
int re2 = 0; //State starter
int bat = 0; //Sensor engine on/off
int fre = 0; //Sensor antitheft
int m=0; //State engine
int li = 0; //State headlights
unsigned long t1 = 0; //Wait time to on starter
unsigned long t2 = 0; //Time limit starter try again
unsigned long t3 = 0; //Time Horn on
unsigned long t4 = 0; //Time limit engine on
unsigned long t5 = 0; //Time light on
unsigned long t6 = 0; //Time flash lights
unsigned long t7 = 0; //Time limit starter on
unsigned long t8 = 0; //Time to on acc
int A = 0; //button A remote control
int B = 0; //button B remote control
int C = 0; //button C remote control
int D = 0; //button D remote control

void setup() {

//Serial.begin(9600); //to make tests when install
pinMode(r1, OUTPUT);
pinMode(r2, OUTPUT);
pinMode(r3, OUTPUT);
pinMode(r4, OUTPUT);
pinMode(r5, OUTPUT);
}

void loop() {

bat=analogRead(A5);
fre=analogRead(A4);
A = analogRead(A1);
B = analogRead(A3);
C = analogRead(A0);
D = analogRead(A2);

/if (A>500 || B>500 || C>500 || D>500){Serial.print("bat: ");Serial.println(bat);
Serial.print("fre: ");Serial.println(fre);Serial.print("m: ");Serial.println(m);
Serial.print("re1: ");Serial.println(re1);Serial.print("re2: ");Serial.println(re2);
Serial.println("");}
/ //unmark this to check states in serial monitor

if (A>500 && m==0){ //button A pressed and engine off
digitalWrite(r1, HIGH); //ignition on
digitalWrite(r3, HIGH); //accesory on, for lights on
digitalWrite(r4, HIGH); //lights on 1 second
t1=millis(); //Wait time to on starter - timer on
t2=millis(); //Time limit starter try again - timer on
t3=millis(); //Time Horn on - timer on
t4=millis(); //Time limit engine on - timer on
t6=millis(); //Time flash lights - timer on
t8=millis(); //Time to on acc - timer on
re1=1; //state ignition on
}

if (B>500 && m==1){ //button B pressed and engine on (if need keys and don't want stop engine)
digitalWrite(r1, HIGH); //ignicion on
re1=1; //state ignition on
}

if (C>500){ //button C pressed - lights on 10 seconds
digitalWrite(r3, HIGH); //acc on (need to lights on)
digitalWrite(r4, HIGH); //lights on
t5=millis(); //Time light on - timer on
li=1; //state lights on
}

continue

if (D>500){ //button D pressed - all off
digitalWrite(r2, LOW); //starter off
digitalWrite(r1, LOW); //ignicion off
digitalWrite(r4, LOW); //lights off
digitalWrite(r3, LOW); //acc off
re1=0; //state ignition off
re2=0; //state starter off
m=0; //state engine off
li=0; //state lights off
}

//make two beeps
if (t3+200<millis() && t3+220>millis() && re1==1 && m==0){//200ms after press A and ign on and engine off
digitalWrite(r5, HIGH); //horn on
}
if (t3+230<millis() && t3+290>millis() && re1==1 && m==0){//after 230ms…
digitalWrite(r5, LOW); //horn off
}
if (t3+300<millis() && t3+320>millis() && re1==1 && m==0){//after 300ms…
digitalWrite(r5, HIGH); //horn on
}
if (t3+330<millis() && t3+400>millis() && re1==1 && m==0){//after 330ms…
digitalWrite(r5, LOW); //horn off
}

if (t6+1000<millis() && t6+2000>millis() && re1==1){ //after 1s and ign on
digitalWrite(r4, LOW); //acc off
digitalWrite(r3, LOW); //lights off
}

if (t1+3000<millis() && t1+3500>millis() && re1==1 && re2==0 && m==0){ //after 3s and ign on and str off and eng off
digitalWrite(r2, HIGH); //starter on
t7=millis(); //Time limit starter on - on
re2=1; //state starter on
}

if (t8+12000<millis() && t8+13000>millis() && m==1 && re1==1){ //after 12s and eng on and ign on
digitalWrite(r3, HIGH); //acc on for lights and a/c or heater
digitalWrite(r4, HIGH); //lights on
}

if (t7+3000<millis() && t7+3500>millis() && re2==1){ //after 3s and starter on - stop str to don’t burn
digitalWrite(r2, LOW); //starter off
t1=millis(); //Wait time to on starter again- timer on
re2=0; //state starter off
}

if (t2+30000<millis() && t2+31000>millis() && bat<300){ //after 30s and engine off - stop try starter engine
digitalWrite(r2, LOW); //starter off
digitalWrite(r1, LOW); //ignition off
digitalWrite(r3, LOW); //acc off
digitalWrite(r4, LOW); //lights off
re1=0; //state ignition off
re2=0; //state starter off
m=0; //state engine off
}

if (bat>300){ //engine on
digitalWrite(r2, LOW); //starter off
re2=0; //state starter off
m=1; //state engine on
}

if (bat<300 && m==1){ //engine off and state engine on
t1=millis(); //start engine again in case engine start and stop again
m=0; //state engine off
}

if (fre>300 && m==1 && re1==1 && re2==0){ //antitheft active and eng on and str off (if no keys in ign, stop engine)
digitalWrite(r1, LOW); //ignition off
digitalWrite(r4, LOW); //lights off
digitalWrite(r3, LOW); //acc off
re1=0; //state ignition off
}

if (t4+900000<millis() && t4+901000>millis() && m==1){ //after 15m and engine on - stop engine
digitalWrite(r1, LOW); //ignition off
digitalWrite(r4, LOW); //lights off
digitalWrite(r3, LOW); //acc off
re1=0; //state ignition off
}

if (t5+10000<millis() && t5+11000>millis() && li==1){ //after 10s and state lights on
digitalWrite(r4, LOW); //lights off
digitalWrite(r3, LOW); //acc off
li=0; //state lights off
}
}

There is a Portugues section...
http://forum.arduino.cc/index.php?board=35.0