Hi!
I'm planing to build rpm limiter for my motorcycle. This is the schematics and code that I wrote, and I'm interested would this work:

This is the code:
const int rpmPin=2;
const int killSwPin=0;
unsigned long lastPulseTime = 0;
unsigned long rpm = 0;
void setup()
{
pinMode(rpmPin,INPUT);
digitalWrite(rpmPin,HIGH);
attachInterrupt(rpmPin,RPMCounter,RISING);
pinMode(killSw,OUTPUT);
}
void loop()
{
if(rpm>=7000)
{
digitalWrite(killSw,HIGH);
}
else
{
digitalWrite(killSw,LOW);
}
}
void RPMCounter()
{
unsigned long now = micros();
unsigned long interval = now - lastPulseTime;
if (interval > 2000)
{
rpm = 60000000UL/(interval);
lastPulseTime = now;
}
}
RPM reading is based on this schematics:
www.sportdevices.com/rpm_readings/index.htmThanks!