first you need to change this in your master-
all of these need to be swapped around.
Code: Select all
PAD_UPstate = (txdata.PAD_UPstate); // Manda lectura del botón Izquierda arriba al Esclavo ***
PAD_DOWNstate = (txdata.PAD_DOWNstate); // Manda lectura del botón Izquierda abajo al Esclavo ***
// int PSB_PAD_LEFT; // El botón Izquierda izquierdo ya esta usado para encender los focos ***
PAD_RIGHTstate = (txdata.PAD_RIGHTstate); // Manda lectura del botón Izquierda derecho al Esclavo ***
BLUEstate = (txdata.BLUEstate); // Manda lectura del botón Cruz azul al Esclavo ***
GREENstate = (txdata.GREENstate); // Manda lectura del botón Triangulo verde al Esclavo ***
PINKstate = (txdata.PINKstate); // Manda lectura del botón Cuadrado rosa al Esclavo ***
REDstate = (txdata.REDstate); // Manda lectura del botón Circulo rojo al Esclavo ***
L1state = (txdata.L1state); // Manda lectura del botón Izquierda delante arriba al Esclavo ***
L2state = (txdata.L2state); // Manda lectura del botón Izquierda delante abajo al Esclavo ***
L3state = (txdata.L3state); // Manda lectura del botón Palo izquierdo abajo al Esclavo ***
R1state = (txdata.R1state); // Manda lectura del botón Derecha delanta arriba al Esclavo ***
R2state = (txdata.R2state); // Manda lectura del botón Derecha delante abajo al Esclavo ***
R3state = (txdata.R3state); // Manda lectura del botón Palo derecho abajo al Esclavo **
Code: Select all
txdata.PAD_UPstate = (PAD_UPstate); // Manda lectura del botón Izquierda arriba al Esclavo ***
txdata.PAD_DOWNstate = (PAD_DOWNstate); // Manda lectura del botón Izquierda abajo al Esclavo ***
// int PSB_PAD_LEFT; // El botón Izquierda izquierdo ya esta usado para encender los focos ***
txdata.PAD_RIGHTstate = (PAD_RIGHTstate); // Manda lectura del botón Izquierda derecho al Esclavo ***
txdata.BLUEstate = (BLUEstate); // Manda lectura del botón Cruz azul al Esclavo ***
txdata.GREENstate = (GREENstate); // Manda lectura del botón Triangulo verde al Esclavo ***
txdata.PINKstate = (PINKstate); // Manda lectura del botón Cuadrado rosa al Esclavo ***
txdata.REDstate = (REDstate); // Manda lectura del botón Circulo rojo al Esclavo ***
txdata.L1state = (L1state); // Manda lectura del botón Izquierda delante arriba al Esclavo ***
txdata.L2state = (L2state); // Manda lectura del botón Izquierda delante abajo al Esclavo ***
txdata.L3state = (L3state); // Manda lectura del botón Palo izquierdo abajo al Esclavo ***
txdata.R1state = (R1state); // Manda lectura del botón Derecha delanta arriba al Esclavo ***
txdata.R2state = (R2state); // Manda lectura del botón Derecha delante abajo al Esclavo ***
txdata.R3state = (R3state); // Manda lectura del botón Palo derecho abajo al Esclavo **
I understand about using too many "if's" but if you use "Else-if's" in the wrong place then the code will not do what you want.
We'll come back to that later....
I had the same problem with my controller hanging up.
when we have sorted your code that problem will go away.
And in your slave you still have to change-
else if (ps2x.Button(PAD_DOWNstate))
// Si presionamos el boton izquierda abajo
{
rxdata.PAD_DOWNstate = (rxdata.PAD_DOWNstate);
digitalWrite(yelLEDpin, HIGH);
// Enciende el Led Amarillo
}
to-
else if (PAD_DOWNstate)
// Si presionamos el boton izquierda abajo
{
digitalWrite(yelLEDpin, HIGH);
// Enciende el Led Amarillo
}
AND DO THE SAME FOR ALL OTHER PADS.
also in slave-
move line 335 ETout.sendData (); // Envía los datos al puerto serie para el ROV Arduino
down to line 473 and add delay 200; to line 474 to give the data time to send.
change line 336 from
ETin.receiveData();
to
while (!ETin.receiveData())
This means that while you have no data, do nothing.
it makes the code wait for the data. if it hasn't got it then there is no point continuing the loop.
Let me know when you have done these steps and send me the new files. it will not work yet, there is more to do....