alright so i got this code online for a 2 step launch control for my car and i want to code in 2 switches so that if both switch 1 (s1) and switch 2 (s2) are flipped off then the 2 outputs in the code (spark 1 and spark 2) will just stay off but if s2 is off and s1 is on then i want the outputs to go through the code normally as if no switches were there, but if s2 is on at all at anypoint then it will go through the code normally as well... if someone can do this for me that would be lovey... thanks ... heres the code..
int rpmpin = 8;
int spark1 = 7;
int spark2 = 6;
int lastrpm = 0;
int cutspark = 0;
long cuttime = 0;
int allowance = 100;
long cutduration = 400;
int cutrpm = 2000;
void setup()
{
Serial.begin(9600);
pinMode(rpmpin, INPUT);
pinMode(spark1, OUTPUT);
pinMode(spark2, OUTPUT);
}
void loop()
{
unsigned long duration = pulseIn(rpmpin, HIGH);
int rpm = (((1000000 / duration) * 60) / 5.1);
if(rpm >= 1)
{
Serial.println(rpm);
if(rpm >= cutrpm && lastrpm >= cutrpm && cutspark == 0)
{
//Serial.println(rpm);
Serial.println("------CUT-------");
cutspark = 1;
cuttime = millis();
digitalWrite(spark1, HIGH);
digitalWrite(spark2, HIGH);
} else
lastrpm = rpm;
if((cutrpm - allowance) > rpm && cutspark == 1)
{
cutduration -= 5;
Serial.println(cutduration);
}
else if ((cutrpm + allowance) < rpm && cutspark == 1)
{
cutduration += 5;
Serial.println(cutduration);
}
}
if(cuttime + cutduration >= millis()) {
cutspark = 0;
digitalWrite(spark1, LOW);
digitalWrite(spark2, LOW);
}
}