advice needed for arduino as diesel injection brain...

Here is a rough sketch, I wrote this based on 2 examples provided with the Arduino IDE "blink without delay", and "Analog Input". The sketch is written to read one trigger sensor, a throttle pot., and be able to fire one injector. You will have to modify the sketch to read 4 injector sensors, and fire 4 injectors.

Perhaps this is enough to get you going. Keep in mind I am a Novice at programming and there is probably lots of room for improvement. :slight_smile:

/*
BASED ON EXAMPLES:
  Analog Input, Blink without Delay
 
 */
int cyl1 = 10;               //cam trigger sensor for injector 1
int trigger1 = LOW;          //variable to hold state of sensor for injector 1
int injectorpin = 13;        // the pin for the injector solenoid
int sensorPin = A0;          // the input pin for the throtttle potentiometer
int sensorValue = 0;         // variable to store the value coming from the sensor
long previousMillis = 0;     // will store last time injection time was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;           // interval at which to fire injectors(milliseconds)


void setup() {
  // declare the injectorpin as an OUTPUT:
  pinMode(injectorpin, OUTPUT);  
  pinMode (cyl1, INPUT);
}

void loop() {

  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);  
  interval = sensorValue;////////////////////////////////////add mapping here or formula
  unsigned long currentMillis = millis(); //update currentMillis
  trigger1 = digitalRead(cyl1);           //read the trigger1 
  
  if(trigger1 == HIGH)
  {
  // turn the injectorpin on
  digitalWrite(injectorpin, HIGH); 
  previousMillis = currentMillis;         //note the time of firing the injector
  }
  
  if (trigger1 == LOW && (currentMillis - previousMillis) > interval)   //if trigger is off and injector has been on long enough, turn off injector
  {          
  // turn the injectorpin off:        
  digitalWrite(injectorpin, LOW);   
  }               
}