MalharD:
Okay,look
1=> 1,44 * (1023/5)=294
2=> 1,83 * (1023/5)=374
3=> 2,56 * (1023/5)=523
4=> 3,29 * (1023/5)=673
5=> 4,14 * (1023/5)=847
6=> 4,60 * (1023/5)=941
The GPS shoud indicate gear 1 if the value is nearly equal to 1,44v or 294 read by analogRead()
So I decided a lower limit approximately, below which the value of analogRead() cannot go and I decoded a upper limit above which the value of analogRead() cannot go.
So the if statements work like-
If the value is above lower limit AND (&&-The Logical AND operator) below the upper limit,print the specific gear.
If you still can't get it,please ask again.
Cheers,
-Malhar
i found the problem before five seconts before you reply,and this the final code
int latchPin = A1;//5 595
int dataPin = A2; //3 595
int clockPin = A3; //6 595
int sensorValue = 0;
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 > 950 && sensorValue <= 1020)
{ digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,MSBFIRST, 63);
digitalWrite(latchPin,HIGH);
}
}
so if anyone have a vstrome and he want to put a gear indicator using the motorcycle GPS this is it..thanks all of you for replys......
and something last how can i make the N in the seven segment to light random all led exept the center?