I'm using an Arduino and I am trying to make a fuel solenoid inject fuel when the throttle position sensor voltage increases by 0.10. I'll give you a little back ground on how the system works on the engine.
The throttle position sensor measures the position essentially of how far you are pushing down the gas pedal on a car.
The throttle position sensor voltage is 0.54 volts when the gas pedal is not being touched by my foot.
When I push the gas pedal, the throttle position sensor voltage increases the further I push the pedal.
When I am maintaining a steady speed, my foot is still on the pedal, and although not accelerating, the throttle position sensor voltage is still HIGHER than 0.54 volts, but it is not varying, it is fixed at one voltage because my foot is steady.
When I apply more pressure to the gas pedal, the throttle position sensor voltage increases and the engine requires more fuel when the throttle position sensor voltage increases by .10 or more. It only needs more fuel for half a second.
So essentially, I cannot have something like the following:
if (TPSvoltage >= 0.54 && TPSvoltage < 0.64){
digitalWrite(fuelSolenoid, HIGH); // turn the fuel solenoid on (HIGH is the voltage level)
Serial.println("Fuel Solenoid Turned on");
delay(500); // wait for half a second
digitalWrite(fuelSolenoid, LOW); // turn the fuel solenoid off by making the voltage LOW
Serial.println("Fuel Solenoid Turned off");
delay(1); // delay in between reads for stability
}
I need something where if only it increases by 0.10 volts regardless of the current throttle position sensor voltage, it will turn the fuel solenoid on.
Can someone please help me figure out this code?
Thank you very much.