Gear indicator problem

Okay,I thought about fluctuations on supply of a vehicle and set the thresholds in if(...),
However,give it a try and see if it works when you are twisting the accelerator of your bike and when you are letting the clutch go slowly in first gear at start of the ride. Voltages change tremendously in thease events, so the voltages for gear 1,etc will also change. You have to take care of those changing voltages and not to lose the count,hence I left some room in the thresholds. However, it's your bike, you can experiment and find the thresholds correctly. Sorry if offended.
-Malhar

thanks again my friend,yes i have this on my mind ,and i modify them to work correctly,can you tell me how i made it, when i press N the sevent segment leds light in a curcle exept the center

Miron27:
thanks again my friend,yes i have this on my mind ,and i modify them to work correctly,can you tell me how i made it, when i press N the sevent segment leds light in a curcle exept the center

Press N ?
Explain. Neutral ??

MalharD:
Press N ?
Explain. Neutral ??

yes when i press N, now in the sevent segment brights the cender led, but i want to bright all the others led in a cyrcle all the time

I don't get it,Please explain more.
What do you mean by "press N"
sorry,
-Malhar

Actually, the condition that will get the most supply problems is at idle with the brake on (motorcycle alternators are not very good at that low a speed and the brake light is a significant drain as is the headlight (at least in the US, the headlight must be on all the time if moving).

Well as you see in the code when the gear switch is in neutral (N) then in the segment light only the center led (63) i want in this situation in segment all the other leds exept center to light in a circle like a zero (0) all the time or to blink

So, you want that the display to show '0' when you are in neutral ?

MalharD:
So, you want that the display to show '0' when you are in neutral ?

Yes and blink

Does it show '0' ?

If yes, just use the following.

int latchPin = A1;//5 595
int dataPin = A2; //3 595
int clockPin = A3; //6 595
int sensorValue = 0;
byte dstate;
unsigned long previousMillis = 0;
const long interval = 1000;//time interval to blink
void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(A4, INPUT);

}
void loop() {
  int sensorValue = analogRead(A4);
  float voltage = sensorValue * (5.0 / 1023.0);

  //1
  if  (sensorValue <= 200 )
  { digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 121);
    digitalWrite(latchPin, HIGH);

  }
  //2
  else if  (sensorValue > 300 && sensorValue <= 375)
  { digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 36);
    digitalWrite(latchPin, HIGH);
  }
  //3
  else if  (sensorValue > 500 && sensorValue <= 522)
  { digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 48);
    digitalWrite(latchPin, HIGH);
  }
  //4
  else if  (sensorValue > 600 && sensorValue <= 671)
  { digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 25);
    digitalWrite(latchPin, HIGH);
  }
  //5
  else if  (sensorValue > 800 && sensorValue <= 844)
  { digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 18);
    digitalWrite(latchPin, HIGH);
  }
  //6
  else if  (sensorValue > 900 && sensorValue <= 950)
  { digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, 2);
    digitalWrite(latchPin, HIGH);
  }
  //N
  else if  (sensorValue > 1000 && sensorValue <= 1020)
  { unsigned long currentMillis = millis();
    if (currentMillis - previousMillis >= interval) {
      previousMillis = currentMillis;
      if ( dstate == true) {

        dstate = false;
        digitalWrite(latchPin, LOW);
        shiftOut(dataPin, clockPin, MSBFIRST, 63);
        digitalWrite(latchPin, HIGH);
      }
      else
      { dstate = false;
      }
    }
  }
}