Connecting real car cluster with pc games (X-sim)

Hello friends,

Can anyone help me with this project posted on the forum.

The only thing needed is to configure the Arduino in X-yes, someone knows about it?

I’m desperate, just need it to complete the project.

int rpm;
int i;
int leds;
int Speed;
int fuel;
int ebrake;
int brake;
int fuelled;
int Turbo;
int gear;
int previous_potion = 0;
int rotate;

char kind_of_data;


void setup(){

 Serial.begin(115200); 

 pinMode(2, OUTPUT);
 pinMode(3, OUTPUT);
 pinMode(5, OUTPUT);
 pinMode(7, OUTPUT);
 pinMode(8, OUTPUT);
 pinMode(10, OUTPUT);
 pinMode(12, OUTPUT);
 pinMode(13, OUTPUT);


}



void loop()
{
 //****************************** READ DATA FROM SERIAL ******************************
 while(Serial.available() > 0)
 {

   kind_of_data = Serial.read();
   if (kind_of_data == 'R' ) Read_Rpm();
   if (kind_of_data == 'S' ) Read_Speed();
   if (kind_of_data == 'F' ) Read_Fuel();
   if (kind_of_data == 'E' ) Read_EBrake();
   if (kind_of_data == 'B' ) Read_Brake();

 }


 //****************************** READ DATA FROM SERIAL END ******************************
}

void  Read_Rpm(){

 delay(1);
 int Rpm100 = Serial.read()- '0';
 delay(1);
 int Rpm10 = Serial.read()- '0';
 delay(1);
 int Rpm1 = Serial.read()- '0';

 int rpm = 100*Rpm100 + 10*Rpm10 + Rpm1;
 analogWrite(7,map(rpm,127,255,75,210));
 if (rpm<135) digitalWrite(13,HIGH);
 if (rpm>135) digitalWrite(13,LOW);
 if (rpm>245) digitalWrite(8,HIGH);
 if (rpm<245) digitalWrite(8,LOW);


}

void Read_Speed(){

 delay(1);
 int Speed100 = Serial.read()- '0';
 delay(1);
 int Speed10 = Serial.read()- '0';
 delay(1);
 int Speed1 = Serial.read()- '0';

 Speed = 100*Speed100 + 10*Speed10 + Speed1;

 tone(12, map(Speed,127,255,0,950)); 

}

void Read_Fuel(){
 delay(1);
 int Fuel100 = Serial.read()- '0';
 delay(1);
 int Fuel10 = Serial.read()- '0';
 delay(1);
 int Fuel1 = Serial.read()- '0';

 fuel = 100*Fuel100 + 10*Fuel10 + Fuel1;

 analogWrite(2,map(fuel,127,255,53,183));
 if (fuel<135) digitalWrite(10,HIGH);
 if (fuel>135) digitalWrite(10,LOW); 

} 


void Read_EBrake(){
 delay(1);
 int EBrake100 = Serial.read()- '0';
 delay(1);
 int EBrake10 = Serial.read()- '0';
 delay(1);
 int EBrake1 = Serial.read()- '0';

 ebrake = 100*EBrake100 + 10*EBrake10 + EBrake1;

 if (ebrake>200) digitalWrite(3,HIGH);
 if (ebrake<200) digitalWrite(3,LOW); 

} 
void Read_Brake(){
 delay(1);
 int Brake100 = Serial.read()- '0';
 delay(1);
 int Brake10 = Serial.read()- '0';
 delay(1);
 int Brake1 = Serial.read()- '0';

 brake = 100*Brake100 + 10*Brake10 + Brake1;

 if (brake>200) digitalWrite(5,HIGH);
 if (brake<200) digitalWrite(5,LOW); 

}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

We need more information to answer the question. I know about X-Plane but very little about X-Sim.

That code looks OK with no obvious problems, although the use of delay(1) is a bit of a hack and it won't be very reliable.

What are you trying to do? What equipment do you have? Do you have datasheets for any of that equipment? Have you tried running this code? What does it do? What would you like it to do differently?