1 (edited by gma5_2005 2021-09-27 02:40:35)

Topic: Indicador de estado de entrada

Cordial saludo

Estoy realizando una aplicacion en la que un LED cambie de color si la entrada 5 del arduino uno es alto, pero al momento de utilizar la interfaz despues de descargar el codigo, el led en la pantalla del telefono no cambia de color .

Qué puede ser?

El código es el siguiente:

Best regard

I am making an application in which an LED changes color if input 5 of the arduino uno is high, but when using the interface after downloading the code, the LED on the phone screen does not change color.

What can be?

The code is the following:

//////////////////////////////////////////////
//        RemoteXY include library          //
//////////////////////////////////////////////

// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__SOFTSERIAL
#include <SoftwareSerial.h>

#include <RemoteXY.h>

// RemoteXY connection settings
#define REMOTEXY_SERIAL_RX 2
#define REMOTEXY_SERIAL_TX 3
#define REMOTEXY_SERIAL_SPEED 9600


// RemoteXY configurate 
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,0,0,1,0,13,0,13,13,1,
  70,40,27,26,9,9,26,37,135,136 };
 
// this structure defines all the variables and events of your control interface
struct {

    // output variables
  uint8_t led_1_r; // led state 0 .. 2

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0

} RemoteXY;
#pragma pack(pop)

/////////////////////////////////////////////
//           END RemoteXY include          //
/////////////////////////////////////////////


const int BOTON = 5;  //Se declara la variable BOTON tipo entero que corresponde al pin 5
const int SALIDA = 6;  //Se declara la variable SALIDA tipo entero que corresponde al pin 6
int ENTRADA;          //Se declara la variable ENTRADA tipo entero que almacenará el valor que se lea en el pin 5

void setup()
{

  RemoteXY_Init ();
 
  Serial.begin(9600);    // configura el puerto serie a 9600bps
   
  pinMode(SALIDA,OUTPUT);  // configura el pin 6 como salida
  pinMode(BOTON,INPUT);  // configura el pin 5 como entrada
  Serial.println("inicio de programa");
 
}

void loop()
{
  RemoteXY_Handler ();
 
  ENTRADA = digitalRead(BOTON);   //El estado del pin 5 se almacena en la variable ENTRADA

  if(ENTRADA==1)
           {
          //digitalWrite(SALIDA,HIGH);
          //delay(2000);

          RemoteXY.led_1_r = 255;
           }
   else
           {
         // digitalWrite(SALIDA,LOW);
         
          RemoteXY.led_1_r = 0;
           }
   
  Serial.println(ENTRADA); // envía valor digital de la entrada al monitor serial */

  //if (digitalRead(5)==HIGH) RemoteXY.led_1_r = 255;
  //else RemoteXY.led_1_r = 0;


}




thanks for your help

2 (edited by Gunner 2021-09-27 07:40:56)

Re: Indicador de estado de entrada

You have a few issues here...

1 - Your posted code was not properly formatted for the topic... please use the <> icon, that way translations wouldn't mess up the code.  ENTRADA translated as INPUT, which is a protected keyword.  Makes it difficult to troubleshoot tongue

2 - This code doesn't make sense...

gma5_2005 wrote:

Cordial saludo
    // output variables
  uint8_t led_1_r; // led state 0 .. 2



  if(ENTRADA==1)
           {
          //digitalWrite(SALIDA,HIGH);
          //delay(2000);

          RemoteXY.led_1_r = 255;
           }

Are you intending to use a LED with 2 states, as the comment implies? (Should be uint8_t led_1; // led state 0 .. 2 if generated properly)

Or an RGB Red Channel, as the code implies? (Should be uint8_t led_1_r; // =0..255 LED Red brightness)

"And voila, which is French for.......'and then I found out.'"

3

Re: Indicador de estado de entrada

Understood, thank you very much, only required:
RemoteXY.led_1 = LOW; or RemoteXY.led_1 = HIGH
for the LED on the display to turn on or off