jeep kart EFI about done

put on a new muffler and are doing some tuning
1 not sure if my print functions are correct as i get nothing on the serial monitor while running or cranking
2 do i need the top "int analog_voltage" or does it save the value in the bottom one?

byte Hall =     2;           // Digital Input pin for rotation sensor, one pulse per revolution
byte injector = 6;           // Digital Output Pin for turning on the injector solenoid
byte TPS =     A0;           // Analog Input Pin for the throttle
int  pulse_time;             // Duration of injector pulse
//int  analog_voltage;         // TPS input  HERE!
const int tpsmin = 150;
const int tpsmax = 1000;

void setup() {

   Serial.begin(9600);                       
   pinMode(Hall, INPUT_PULLUP);
   pinMode(TPS, INPUT);
   pinMode(injector, OUTPUT);

   delay (300);                          //  wait for fuel pressure
   digitalWrite(injector,HIGH);          //  start primer
   delay (50);
   digitalWrite(injector,LOW);           //  end primer
} 

void loop() {
   while (digitalRead(Hall)==LOW){}                        // do nothing
   
  int analog_voltage=analogRead(TPS);                      // engine load AND HERE!
  int load = map(analog_voltage, tpsmin, tpsmax, 0, 5);
  pulse_time=6;                                            // idle ms

  switch (load)
  {
    case 0:
     pulse_time+=0;
     break;

    case 1:
     pulse_time+=3;
     break;

    case 2:
     pulse_time+=5;
     break;

    case 3:
     pulse_time+=6;
     break;

    case 4:
     pulse_time+=7;
     break;

    case 5:
     pulse_time+=8;
     break;
  }
         
  Serial.println(pulse_time);                     // bunch of jibberish to ponder
  Serial.println(load);

  digitalWrite(injector,HIGH);                    // Turn the injector on
  delay(pulse_time);                              // Amount of time to leave the injector on
  digitalWrite(injector,LOW);                     // Turn the injector off

   while (digitalRead(Hall)==HIGH){}              // Wait for LOW
}

When you have int analog_voltage it creates a new variable so you should only do that in one place in the program. If you want to refer to the same variable again then just do analog_voltage without the int.

Where you have it now inside loop() will work fine for your program.

I am very suspicious of this line

while (digitalRead(Hall)==LOW){}

as it leaves the Arduino twiddling its thumbs until something changes - but maybe that's what is appropriate for your project. What is going on while the Arduino is waiting?

...R

At least start with....

Serial.begin(9600);
Serial.println("jeep kart EFI started...");

And you'll know if your Arduino is up and running and the serial is working. It will also tell you if it reboots for some reason.
Add other debugging as required so you can see where the Arduino is "stuck".

What kind of "gibberish"?

  Serial.println(pulse_time);                     // bunch of jibberish to ponder
  Serial.println(load);

If you are getting rubbish out of the serial connection, one or more of...
a) Incorrect baud rate/serial parameters selected
b) Incorrect wiring
c) Trying to connect RS232 logic levels (+/-15v) directly into Arduino TTL Tx/Rx pins (0 to 3.3/5V)

Edit: How wide is your HIGH pulse from the hall sensor?

robin2
i want analog_voltage to store the read value each time through the loop. this is my only user input on the fuel injection
i like the idea of having arduino commanded to do nothing in a time where you want it to do nothing.
is it bad to do this somehow?

pcbbc
great idea on the start print!
i just want some display of what it is outputting, off the analog_voltage received. i was being cheeky on the rubbish comment
the 2 parameters are all i need to run. i really want to see this info while running
i welded a 1/2" wide steel lug on the crank coupler. 1 pulse per revolution

ideally i would die for a LED display on the dash of RPM, Ms delay value, and analog_voltage value!!!!!

i would like to add in a cranking enrichment feature. this would be attached to the start button. so when cranking the digital pin 3 would go low.

byte Hall = 2;           // Digital Input pin for rotation sensor, one pulse per revolution
byte Cranking =3;          // cranking enrichment 
byte injector =6;           // Digital Output Pin for turning on the injector IGBT
byte TPS =    A0;           // Analog Input  from the throttle
int  pulse_time;             // Duration of injector pulse
const int tpsmin = 150;
const int tpsmax = 1000;

void setup() {

   Serial.begin(9600); 
   Serial.println( Jeep Kart Powered Up!)                      
   pinMode(Hall, INPUT_PULLUP);
   pinMode(Cranking, INPUT_PULLUP);
   pinMode(TPS, INPUT);
   pinMode(injector, OUTPUT);
   

   delay (2000);                          //  wait for fuel pressure
   digitalWrite(injector,HIGH);          //  start primer
   delay (200);
   digitalWrite(injector,LOW);           //  end primer
}

void loop() {
   while (digitalRead(Hall)==LOW){}                        // do nothing
   
  int analog_voltage=analogRead(TPS);                      // engine load 
  int load = map(analog_voltage, tpsmin, tpsmax, 0, 5);
  pulse_time=6;                                            // idle ms


//////////////////

 while (digitalRead(Cranking)==LOW){           // i bet this is totally wrong but maybeeeeee not?
    pulse_time+=3; }

/////////////////

  switch (load)
  {
    case 0:
     pulse_time+=0;
     break;

    case 1:
     pulse_time+=3;
     break;

    case 2:
     pulse_time+=5;
     break;

    case 3:
     pulse_time+=6;
     break;

    case 4:
     pulse_time+=7;
     break;

    case 5:
     pulse_time+=8;
     break;
  }
         
  Serial.println(pulse_time);                     // bunch of jibberish to ponder
  Serial.println(load);

  digitalWrite(injector,HIGH);                    // Turn the injector on
  delay(pulse_time);                              // Amount of time to leave the injector on
  digitalWrite(injector,LOW);                     // Turn the injector off

   while (digitalRead(Hall)==HIGH){}              // Wait for LOW
}