## Abbreviations  
Acronyms  
AWD  
BLDC  
BMS  
Battery management system  
BoP  
Balance of plant  
FWD  
Front two-wheel drive  
#define pin_OUT_Avance_Der 13 //Right wheels speed control
#define pin_OUT_Reversa_Der 12 //Right wheel advance control
#define pin_OUT_Reversa_Izq 9 //Left wheel advance control
#define pin_OUT_Avance_Izq 11 //Left wheels speed control
#define pin_OUT_ON_OFF 10 //Pin ON/OFF  
//Libraries
#include < EnableInterrupt.lb> //Interrupts library  
//-------------------------------------- //Variable declaartion  
//Constants declarations  
float RC_Avance_consigma, RC_Reversa_consigna, RC_Reversa_consigna_inversa,  
RC_ON_OFF_consigna; //RC variables  
double RC_Giro_consigna, RC_Avance_Perecha, RC_Avance_Izquierda; //RC variables  
//Constant RC  
//Advance  
const int RC_max_Avance_raw = 2010;  
const int RC_min_Avance_raw = 1000;  
const float Ardu_max_Avance = 255;  
const float Ardu_min_Avance = 0;  
//Turn  
const float RC_max_Giro_raw = 2010;  
const float RC_min_Giro_raw = 965;  
const float Ardu_max_Giro = 16;  
const float Ardu_min_Giro = -10;  
//SWITCH REVERSE  
const float RC_max_Reversa_raw = 2010;  
const float RC_min_Reversa_raw = 940;  
const int Ardu_max_Reversa = 255;  
const int Ardu_min_Reversa = 0;  
//SWITCH ON/OFF  
const float RC_max_ON_OFF_raw = 2000;  
const float RC_min_ON_OFF_raw = 960;  
const int Ardu_max_ON_OFF = 255;  
const int Ardu_min_ON_OFF = 9;  
//Interrupts declarations  
//-------------------------------------- // RC advance  
volatile long Avance_HIGH_us;  
volatile int RC_Avance_raw;  
void INT_AvanceO {  
if (digitalRead(pin_INT_Avance) == HIGH) Advance_HIGH_us = microsO;  
if (digitalRead(pin_INT_Avance) == LOW) RC_Avance_raw = microsO - Avance_HIGH_us;}  
//RC turn  
volatile long Giro_HIGH_us;  
volatile int RC_Giro_raw;  
void INT_GiroO {  
if (digitalRead(pin_INT_Giro) == HIGH) Giro_HIGH_us = microsO;  
if (digitalRead(pin_INT_Giro) == LOW) RC_Giro_raw = microsO - Giro_HIGH_us;}  
//SWITCH REVERSE  
volatile long Reversa_HIGH_us;  
volatile int RC_Reversa_raw;  
void INT_ReversaO {  
if (digitalRead(pin_INT_Reversa) == HIGH) Reversa_HIGH_us = microsO;  
if (digitalRead(pin_INT_Reversa) == LOW) RC_Reversa_raw = microsO - Reversa_HIGH_us;}  
//SWITCH ON/OFF  
volatile long ON_OFF_HIGH_us;  
volatile int RC_ON_OFF_raw;  
void INT_ON_OFFO {  
if (digitalRead(pin_INT_ON_OFF) == HIGH) ON_OFF_HIGH_us = microsO;  
if (digitalRead(pin_INT_ON_OFF) == LOW) RC_ON_OFF_raw = microsO - ON_OFF_HIGH_us;}  
// Programme main funtion //------------------------------------------------- void setupO { // RC interruptions // pinNode(pin_INT_Avance, INPUT_PULULUIP); // Advance speed enableInterrupt(pin_INT_Avance, INT_Avance, CHANGE); pinMode(pin_INT_Giro, INPUT_PULUIP); // Turn right-left enableInterrupt(pin_INT_Giro, INT_Giro, CHANGE); pinMode(pin_INT_Revers, INPUT_PULULUIP); // Switch reverse enableInterrupt(pin_INT_Revers, INT_Revers, CHANGE); pinMode(pin_INT_ON_OFF, INPUT_PULUIP); // Switch on/off enableInterrupt(pin_INT_ON_OFF, INPUT_ON_OFF, CHANGE); //Output controllers pinMode(pin_OUT_Avance_Izq, OUTPUT); pinMode(pin_OUT_Avance_Per, OUTPUT); pinMode(pin_OUT_Revers_Izq, OUTPUT); pinMode(pin_OUT_Revers_per, OUTPUT); pinMode(pin_OUT_ON_OFF, OUTPUT); //Rebastic break pinMode(pin_Freno, OUTPUT); // Serial port spped Serial.begin(115200);} void loopO { //RC-Arduino mapping RC_Avance_consigna = map(RC_Avance_raw, RC_min_Avance_raw, RC_max_Avance_raw,  Arduino_min_Avance, Ardu_max_Avance); RC_Giro_consigna = map(RC_Giro_raw, RC_min_Giro_raw, RC_max_Giro_raw,  Arduino_Giro, Ardu_max_Giro); RC_Revers_consigna = map(RC_Revers_raw, RC_min_Revers_raw, RC_max_Revers_raw,  Arduino_min_Revers, Ardu_max_Revers); RC_ON_OFF_consigna = map(RC_ON_OFF_raw, RC_min_ON_OFF_raw, RC_max_ON_OFF_raw,  Arduino_ON_OFF, Ardu_max_ON_OFF); //advance logic ifRC_Revers_consigna <50}{ RC_Revers_consigna_inversa = 240;} else{RC_Revers_consigna_inversa = 30;} //Turn logoc ifRC_Giro_consigna > 2.0}{ RC_Avance_Izquierda = RC_Avance_consigna; RC_Avance_Derecha = RC_Avance_consigna*(1.0-(RC_Giro_consigna/10.0));} else{IF(RC_Giro_consigna < -2.0}{ RC_Avance_Izquierda = RC_Avance_consigna*(1.0+(RC_Giro_consigna/10.0)); RC_Avance_Derecha = RC_Avance_consigna;} else{ RC_Avance_Izquierda = RC_Avance_consigna;} RC_Avance_Derecha = RC_Avance_consigna;} analogWrite(pin_OUT_Revers_Der, RC_Revers_consigna); analogWrite(pin_OUT_Revers_Izq, RC_Revers_consigna_inversa); analogWrite(pin_OUT_ON_OFF, RC_ON_OFF_consigna); analogWrite(pin_OUT_Avance_Izq, RC_Avance_Izquierda); analogWrite(pin_OUT_Avance_Der, RC_Avance_Derecha); } ```