0% found this document useful (0 votes)
642 views1 page

Arduino Launch Control

This code is monitoring engine RPM using an input pin and triggering the ignition coil to cut spark above a threshold RPM. It calculates RPM from the pulse width on the input pin, triggers the ignition cut when RPM rises above a threshold, and adjusts the cut duration +/- 5ms if RPM is outside an allowance range during the cut.

Uploaded by

Ivan Intro
Copyright
© Attribution Non-Commercial (BY-NC)
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)
642 views1 page

Arduino Launch Control

This code is monitoring engine RPM using an input pin and triggering the ignition coil to cut spark above a threshold RPM. It calculates RPM from the pulse width on the input pin, triggers the ignition cut when RPM rises above a threshold, and adjusts the cut duration +/- 5ms if RPM is outside an allowance range during the cut.

Uploaded by

Ivan Intro
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 1

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 = 3000; 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); } }

You might also like