Arduino Gearshift indicator

This is a gear shift indicator for vehicles using an arduino nano and seven segments led
you can improve these prototype and integrated on the dash board

[code]
int a=6;
int b= 7;
int c= 8;
int d=9;
int e=10;
int f=11;
int g=12;

#define gear1 A6
#define gear2 A7
#define gear3 5
#define gear4 4
#define gear5 2
#define rever 3

void setup() {
  Serial.begin(9600);
  pinMode(gear1,INPUT);
  pinMode(gear2,INPUT);
  pinMode(gear4,INPUT);
  pinMode(gear4,INPUT);
  pinMode(gear5,INPUT);
  pinMode(rever,INPUT);
 pinMode(a,OUTPUT);
 pinMode(b,OUTPUT);
 pinMode(c,OUTPUT);
 pinMode(d,OUTPUT);
 pinMode(e,OUTPUT);
 pinMode(f,OUTPUT);
 pinMode(g,OUTPUT);
 
}

void loop() {
int g1 =analogRead(gear1); 
int g2 =analogRead(gear2); 
int g3= digitalRead(gear3);
int g4= digitalRead(gear4);
int g5= digitalRead(gear5);
int r= digitalRead(rever);
 if (g1<100)
 {limpia();
    primera();}
 else if (g2<100) 
    {limpia();
    segunda();}
else if (g3==LOW)
  {limpia();
    tercera();}
 else if  (g4==LOW)
  {limpia();
    cuarta();}
    else if (g5==LOW)
  {limpia();
    quinta();}
       else if (r==LOW)
  {limpia();
    reversa();}
    
  else {limpia();
  neutral();
  }
  //delay(10);
 }


void neutral(){
 digitalWrite(c,HIGH);
 digitalWrite(e,HIGH);
 digitalWrite(g,HIGH);
 
  }
  void reversa(){
 digitalWrite(c,LOW);
 digitalWrite(e,HIGH);
 digitalWrite(g,HIGH);
  }
  void primera(){
 digitalWrite(c,HIGH);
 digitalWrite(b,HIGH);
  }
  void segunda(){
 digitalWrite(a,HIGH);
 digitalWrite(b,HIGH);
 digitalWrite(d,HIGH);
 digitalWrite(e,HIGH);
 digitalWrite(g,HIGH);
  }
  void tercera(){
 digitalWrite(a,HIGH);
 digitalWrite(b,HIGH);
 digitalWrite(c,HIGH);
 digitalWrite(d,HIGH);
 digitalWrite(g,HIGH);
  }
  void cuarta(){
 digitalWrite(b,HIGH);
 digitalWrite(c,HIGH);
 digitalWrite(f,HIGH);
 digitalWrite(g,HIGH);
   }

  void quinta(){
 digitalWrite(a,HIGH);
 digitalWrite(c,HIGH);
 digitalWrite(d,HIGH);
 digitalWrite(f,HIGH);
 digitalWrite(g,HIGH);
  }
  void limpia(){
 digitalWrite(a,LOW);
 digitalWrite(b,LOW);
 digitalWrite(c,LOW);
 digitalWrite(d,LOW);
 digitalWrite(e,LOW);
 digitalWrite(f,LOW);
 digitalWrite(g,LOW);
  }
 
[/code]

A bit more information, are these passenger type of vehicles or models. My SWAG is model because production cars do not use Arduinos and the selectors are different.

Esquema-gearshift.pdf (34,8 KB)

1 Like

This is the prototype: Facebook

Nice Job on the schematic.

Hi, @luis_vs schematic

Does the brightness of the segments change as the digits displayed change?

Tom... :grinning: :+1: :coffee: :australia: