thanx for your help !!
what type of signal did you use ? when you say "It only uses 1 sensor per revolution"
this is the way i was planing on reading the rpm signal
void loop()
{
//check for current RPM
pulseDuration = pulseIn(signalRPM, LOW);
pulseDuration = pulseDuration + pulseIn(signalRPM, HIGH);
currentRPM = ((60000000/pulseDuration)*0.5);
it is part of a other guys program , he uses the rpm to power a RGB led so the led changes color as the revs reach certain points dictated by the program.
so what i was thinking of adopting his program, because the signals on his car and mine are the same
(square signals, 12V and GND in 50/50 proportion). Then instead of only a led lighting up , switch a relay.
and adjust the "set" rpm value with a pod instead of hard writing it into the program.
here is HIS full program.
// HARDWARE PIN CONFIG
int ledR = 6;
int ledG = 10;
int ledB = 11;
int buzzer = 8;
int signalRPM = 7;
// SETTINGS
int alertRPM = 5600;
int buzzerFreq = 3000;
// HELPERS
int currentRPM = 1000;
int borderNoRPM = 300;
int borderLevel1 = alertRPM * 0.8; //4400 by default
int borderLevel2 = alertRPM * 0.97; //5335 by default
int borderLevel3 = alertRPM * 1.03; //5665 by default
int borderLevel4 = alertRPM * 1.1; //6050 by default
int pulseDuration;
// ALERTS
int alertNoRPM()
{
analogWrite(ledR, 255);
analogWrite(ledG, 255);
analogWrite(ledB, 128);
noTone(buzzer);
delay(200);
analogWrite(ledR, 0);
analogWrite(ledG, 0);
analogWrite(ledB, 0);
delay(200);
}
int alertLevel0()
{
analogWrite(ledR, 0);
analogWrite(ledG, 0);
analogWrite(ledB, 0);
noTone(buzzer);
}
int alertLevel1()
{
analogWrite(ledR, 0);
analogWrite(ledG, 255);
analogWrite(ledB, 0);
noTone(buzzer);
}
int alertLevel2()
{
analogWrite(ledR, 0);
analogWrite(ledG, 0);
analogWrite(ledB, 255);
noTone(buzzer);
}
int alertLevel3()
{
analogWrite(ledR, 255);
analogWrite(ledG, 0);
analogWrite(ledB, 0);
noTone(buzzer);
}
int alertLevel4()
{
analogWrite(ledR, 0);
analogWrite(ledG, 0);
analogWrite(ledB, 0);
tone(buzzer, buzzerFreq, 75);
delay(50);
analogWrite(ledR, 255);
delay(50);
}
void setup()
{
//setup procedure
pinMode(ledR, OUTPUT);
pinMode(ledG, OUTPUT);
pinMode(ledB, OUTPUT);
pinMode(signalRPM, INPUT);
pinMode(buzzer, OUTPUT);
//welcome procedure
alertLevel1();
delay(200);
alertLevel2();
delay(200);
alertLevel3();
delay(200);
alertLevel4();
delay(200);
alertLevel0();
}
void loop()
{
//check for current RPM
pulseDuration = pulseIn(signalRPM, LOW);
pulseDuration = pulseDuration + pulseIn(signalRPM, HIGH);
currentRPM = ((60000000/pulseDuration)*0.5);
//start alert for currentRPM
if(currentRPM>=0 && currentRPM<=borderNoRPM)
{
alertNoRPM();
}
else
{
if(currentRPM>borderNoRPM && currentRPM<=borderLevel1)
{
alertLevel0();
}
if(currentRPM>borderLevel1 && currentRPM<=borderLevel2)
{
alertLevel1();
}
if(currentRPM>borderLevel2 && currentRPM<=borderLevel3)
{
alertLevel2();
}
if(currentRPM>borderLevel3 && currentRPM<=borderLevel4)
{
alertLevel3();
}
if(currentRPM>borderLevel4)
{
alertLevel4();
}
}
}
do you think im on the right track ??