Someone is helping me get the data out of a driving simulator game to drive real gauges and lights on a real dashboard,
He's written me a .dll file that starts with the game (the game is designed to allow all vehicle data to be read with a plugin)
We are starting with simple things, to turn a led on or off depending on if the vehicles ignition is on or off,
the dll reads the game data, and sends a value of 0 or 1 depending on the ignition status, preceded by the letter E so let the arduino know it's data relating to the electricity state,
I click the connect button on the dll's form, the arduino starts recieving data, and turns on the led set up to show if the connection is on or off, but the led for the electricity status also comes on, even tho it is off in the game, and toggeling the electricity status in the game, the form shows it changing, but the arduino isnt changing the led state.
Can someone look at the code and let me know if it's something in the arduino code, or i need to look at the dll part please.
int elec;
char kind_of_data;
void setup(){
Serial.begin(115200);
pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
}
void loop()
{
//****************************** READ DATA FROM SERIAL ******************************
while(Serial.available() > 0)
{
kind_of_data = Serial.read();
if (kind_of_data == 'E' ) Read_Elec();
if (kind_of_data == 'I' ) digitalWrite(23,HIGH);
if (kind_of_data == 'O' ) digitalWrite(23,LOW);
}
//****************************** READ DATA FROM SERIAL END ******************************
}
void Read_Elec(){
delay(1);
int Elec = Serial.read();
if (elec=1) digitalWrite(22,HIGH);
if (elec=0) digitalWrite(22,LOW);
}