Propane injection software compiles, uploads, doesn't work Looking for some help here. I have written out some code to add propane injection for my forklift. It is supposed to read three analog inputs, add them together and multiply the sum by three. There is an interrupt which is triggered by a hall effect sensor which is supposed to fire a solenoid valve for a duration of microseconds. I have mocked this up on a breadboard with a attiny85 pulsing the hall effect pin and nothing happens. Would appreciate some one having a look at the code and letting me know where I went wrong. Thanks.

const byte interruptPin = 2; //this is the interrupt pin hall sensor//
int mpPin = A3; //manifold pressure sensor//
int tpsPin = A4; //throttle position sensor//
int tunePin = A5; //tune pot 10k//
volatile byte inj; //this will end up being the duration of the injector pulse//
int mpValue = 0; //setting manifold variable to zero//
int tpsValue = 0; //setting throttle positon sensor value to zero//
int tuneValue = 0; //setting tune value sensor variable to zero//
int injValue = 0; //setting injection variable to zero//

void setup() {
    pinMode(12, OUTPUT);  //this is the pin that fires the injector//
    pinMode(interruptPin, INPUT_PULLUP); //set the interrupt pin to high pull up //
    attachInterrupt(digitalPinToInterrupt(interruptPin), shot, LOW);  //set the interrupt to trigger shot isr on low//
}

void loop() {
    tpsValue = analogRead(tpsPin); //read the throttle positon sensor//
    mpValue = analogRead(mpPin);//read the manifold pressure sensor//
    tuneValue = analogRead(tunePin); //read the tune sensor//
    injValue = (tpsValue + mpValue + tuneValue) * 4; // add the three sensors together and assign the value to inj//
}

void shot() {
    digitalWrite, 12, HIGH; // initilize injector powerup//
    delayMicroseconds(inj); //delay the calculated value  in microseconds//
    digitalWrite, 12, LOW; //shut down the injector//
}
I can see two things wrong with your code at first glance.  First is the kind of interrupt you're using:

attachInterrupt(digitalPinToInterrupt(interruptPin), shot, LOW);


A LOW interrupt keeps triggering over and over again all the time the input is low.  It's a special interrupt type that is seldom used for anything except waking up the MCU or handling external peripherals with persistent interrupt indication.  Instead you should be using FALLING which will trigger once and once only when the input transitions from HIGH to LOW.

attachInterrupt(digitalPinToInterrupt(interruptPin), shot, FALLING);


Secondly you have two variables that seem to be intended to do the same thing - store the delay time for your output pulse.  And that's caused confusion:

injValue = (tpsValue + mpValue + tuneValue) * 4; // add the three sensors together and assign the value to inj//


... and then later ...

delayMicroseconds(inj); //delay the calculated value  in microseconds//


In your comments you reference the second variable, but the code uses the first one. Change that so it uses just one (volatile) variable:

inj = (tpsValue + mpValue + tuneValue) * 4; // add the three sensors together and assign the value to inj//


Alternatively, and perhaps much safer, is to assign the result of the calculation inside a critical section, in which case having two variables is useful:

injValue = (tpsValue + mpValue + tuneValue) * 4; // add the three sensors together and assign the value to inj//
noInterrupts();
inj = injValue;
interrupts();


This will prevent your interrupt triggering whilst the value is being calculated and placed into the inj variable which could result in the inj variable containing gibberish, which could cause your engine to explode.