0% found this document useful (0 votes)
164 views

Arduino Start Stop

This document describes an Arduino-based push button ignition switch for automobiles. It includes code for a switch that can start the ignition, engage the starter, and turn accessories on/off for a 1988-2000 Honda Civic/CRX. The code defines pin connections for buttons, LED outputs, and relays to control ignition, starter, and accessories. It uses states and timers to implement the switch functionality through the Arduino loop function.

Uploaded by

Junior Magnus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views

Arduino Start Stop

This document describes an Arduino-based push button ignition switch for automobiles. It includes code for a switch that can start the ignition, engage the starter, and turn accessories on/off for a 1988-2000 Honda Civic/CRX. The code defines pin connections for buttons, LED outputs, and relays to control ignition, starter, and accessories. It uses states and timers to implement the switch functionality through the Arduino loop function.

Uploaded by

Junior Magnus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

// (C) 2014 Scott Hubble. NOT FOR COMMERCIAL USE.

//Push button ignition switch for automobiles.


//Made for 1988-2000 Honda Civic/CRX, but may be adapted to other vehicles.
//By Scott Hubble. Original version started 2114 Aug. 11.
//Ver. 6 started 2014 Aug. 15. Completed 2014 Aug. 15 @ 23:10 -7 UTC.
//UPDATE: 2014 Aug. 16 - Added LED output for button illumination.
//UPDATE: 2014 OCT. 2 - Changed for standalone Atmega.
int b1 = 3; //Start button.
int b2 = 2; //Clutch interlock switch.
int acc = 9; //Accessory output.
int ign = 8; //Ignition output.
int st = 7; //Starter output.
int ledPin = 12; //LED for button illumination.
int accLed = 11; //ACC indicator.
int onLed = 13; //ON indicator.

long unsigned time = 0; // Timer.


long unsigned time2 = 0; //2nd timer.
int ledFlash = 0;
int ledFlash2 = 0;
int ledOn = 0;
int b1Stat = 0; //Was the primary switch pressed?
int b2Stat = 0; // Secondary switch pressed?
int did = 0;
int did2 = 0;
int did3 = 0;
int on = 0;
int on2 = 0;

void setup()
{
pinMode(b1, INPUT);
pinMode(b2, INPUT);
pinMode(acc, OUTPUT);
pinMode(ign, OUTPUT);
pinMode(st, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(accLed, OUTPUT);
pinMode(onLed, OUTPUT);
time = millis();
time2 = millis();
digitalWrite(acc, HIGH);
digitalWrite(ign, HIGH);
digitalWrite(st, HIGH);
digitalWrite(accLed, HIGH);
digitalWrite(onLed, HIGH);
digitalWrite(ledPin, HIGH);
}

void loop()
{
// -------------------------Read the bottons:-----------
if(digitalRead(b1) == HIGH && b1Stat == 0){
b1Stat++;
on++;
delay(90);
}
if(digitalRead(b1) == LOW && b1Stat == 1){
b1Stat--;
on--;
delay(90);
}

if(digitalRead(b2) == HIGH && b2Stat == 0){


b2Stat++;
on2++;
delay(90);
}
if(digitalRead(b2) == LOW && b2Stat == 1){
b2Stat--;
on2--;
delay(90);
}
//--------------------Operation:---------------------------
if(on == 1 && on2 == 1 && did == 0){ // Start engine, IGN on.
digitalWrite(acc, HIGH);
digitalWrite(ign, LOW); //Write LOW to activate relay.
digitalWrite(st, LOW);
did = 1;
did2 = 0;
did3 = 1;
ledOn = 1;
}

if(on == 0 && did == 1){ //Starter off.


digitalWrite(st, HIGH);
digitalWrite(onLed, LOW);
did = 2;
}

if(did == 2 && on == 0){ //ACC on after engine start.


digitalWrite(acc, LOW);
digitalWrite(accLed, HIGH);
did = 3;
}

if(did == 3 && on == 1){ //Turn everything off.


digitalWrite(ign, HIGH);
digitalWrite(acc, HIGH);
digitalWrite(onLed, HIGH);
digitalWrite(accLed, HIGH);
did = 4;
ledOn = 0;
time2 = 0;
}

if(did == 4 && on == 0){


did = 0;
did2 = 0;
did3 = 0;
}
//-----------------NON STARTER OPERATION--------------------

if(on == 1 && did2 == 0 && did3 == 0){ //Push for ACC


digitalWrite(acc, LOW);
digitalWrite(accLed, LOW);
did2 = 1;
ledOn = 1;
}

if(on == 0 && did2 == 1 && did3 == 0){


did2 = 2;
}

if(did2 == 2 && on == 1 && on2 == 0){ //IGN without start


digitalWrite(ign, LOW);
digitalWrite(onLed, LOW);
digitalWrite(accLed, HIGH);
did2 = 3;
}

if(on == 0 && did2 == 3 && did3 == 0){


did2 = 4;
}

if(did2 == 4 && on == 1 && on2 == 0){ //ALL SYSTEMS OFF.


digitalWrite(ign, HIGH);
digitalWrite(acc, HIGH);
digitalWrite(accLed, HIGH);
digitalWrite(onLed, HIGH);
did2 = 5;
ledOn = 0;
time2 = 0;
}

if(did2 == 5 && on == 0){


did2 = 0;
}
//-----------------LED OUTPUT/BUTTON FLASH/illum.-------------------
if(ledOn == 1 && time2 == 0){
digitalWrite(ledPin, LOW);
time2 = 1;
}else if(millis() - time > 5000 && ledOn == 0 && b2Stat == 0){
digitalWrite(ledPin, LOW);
time = millis();
ledFlash = 1;
}
if(millis() - time > 100 && ledFlash == 1 && ledOn == 0 && b2Stat == 0){
digitalWrite(ledPin, HIGH);
time = millis();
ledFlash = 0;
}
if(b2Stat == 1 && b1Stat == 0 && ledOn == 0){
digitalWrite(ledPin, LOW);
delay(50);
digitalWrite(ledPin, HIGH);
delay(60);
}
}

You might also like