Je m'approche du but
J'ai quasiment terminé le programme, je poste une version light fonctionnel :
/* R13 Consult Auto Transmission By 200sx200*/
boolean recept = false;
boolean displayP = false;
byte display1[37];//Open Display
//Consult
byte consult[28];
//int gauges
int tps;
int sped;
// Led remplace solenoid
const int Solenoid_A = 31;
const int Solenoid_B = 33;
const int Solenoid_Clutch = 35;
const int Solenoid_Lockup = 37;
//const int Solenoid_Pressure = 39;
// on when pin is high
// off when pin is low
const int SON = LOW;
const int SOFF = HIGH;
//vitesse
int vitesse = 1;
//setup
void setup() {
Serial.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);
pinMode(Solenoid_A, OUTPUT); //solenoid A
pinMode(Solenoid_B, OUTPUT); //solenoid B
pinMode(Solenoid_Clutch, OUTPUT); //solenoid Overrun Clutch
pinMode(Solenoid_Lockup, OUTPUT); //solenoid Lock-up
//pinMode(Solenoid_Pressure, OUTPUT); //solenoid Line Pressure
}
void loop() {
if ( recept == false) {
displayO();
}
while (recept == true) {
Serial2.readBytes(consult, 28);
if (consult[0] == 0xFF) {
byteconsult();
//Print();
//-----------------------------Gearbox----------------------------------//
if (recept == true) {
byteconsult();
if (tps >= 3) { //Volt position papillons (5.1V pour 100%)
if (sped < 10) {
Vitesse1();
}
if (sped > 10 && sped <= 14) {
Vitesse2();
}
}
}
//-----------------------------Gearbox----------------------------------//
}
}
}//End Loop
//-----------------------Open Display-----------------------//
void displayO() {
Serial3.readBytes(display1, 37);
if ((display1[0] == 6) && (display1[1] == 41) && (display1[3] == 41) && (display1[35] == 41)) {
Serial.println("Open Display Windows detected");
recept = true;
}
}
void byteconsult() {
//Speed kph
sped = consult[4] * 2;
//Throttle Position voltage
tps = consult[11];
tps = ((tps * 20) / 1000.0);
}
void Print() {
Serial.print("Speed kph="); Serial.println(sped);
Serial.print("Throttle="); Serial.println(tps);
}
// 1 => BC
void Vitesse1() {
Serial.println("Vitesse1");
digitalWrite(Solenoid_A, SON);
digitalWrite(Solenoid_B, SON);
digitalWrite(Solenoid_Clutch, SON);
digitalWrite(Solenoid_Lockup, SOFF);
//digitalWrite(Solenoid_Pressure, SOFF);
}
// 2 => ABDEG
void Vitesse2() {
Serial.println("Vitesse2");
digitalWrite(Solenoid_A, SOFF);
digitalWrite(Solenoid_B, SON);
digitalWrite(Solenoid_Clutch, SON);
digitalWrite(Solenoid_Lockup, SOFF);
//digitalWrite(Solenoid_Pressure, SOFF);
}
Me reste à généré le code avec les 3 boutons dont le 3eme(mode manuel) prenant le dessus sur tous et donnant accès au 2 autres(+et-).