Start a new topic

button pressd

I'm performing a panel, when pressed it keeps the relay activated only the relay will turn off if you stop pressing, I need to know which code I put in the b0 to perform this function being only in touch.


void b1PopCallback(void *ptr)

{

    NexButton *btn2 = (NexButton *)ptr;

 

        digitalWrite(9, LOW);

        delay(100);

        digitalWrite(9, HIGH);

        Serial.println("Step out");

   

       

   

}


Please see the Arduino-Nextion Examples.

I didn't waste time updating to answer this many times.

But when you hold down ,,, it does something, if you do not keep it pressed to ... this I just saw some examples but I do not find anything if you have to send the page

Please define in clear words what is your exact request step by step

- what you are trying to accomplish

- what steps have you taken on the Nextion side HMI

- what steps have you taken on the MCU side (which MCU, etc)

- what successes you have had

- what is your issue

- what MCU, programming language and compilers.

Arduino mega + nextion publisher

Use this to activate the relay with the touch of the button,

Void b0PopCallback (void * ptr)

{

     NexButton * btn1 = (NexButton *) ptr;

 

     

         DigitalWrite (9, LOW);

         Delay (500);

         DigitalWrite (9, HIGH);

         Serial.println ("Step out");

}

 

Only that it only has to trigger once I want it to be relay active only it was not active when the button was not pressed.

Examples contains a CompPage

http://support.iteadstudio.com/support/discussions/topics/11000009208


What Nextion Return Data is sent is in the Nextion Instruction Set

https://www.itead.cc/wiki/Nextion_Instruction_Set


How IteadLib 0x65 is handled, explained again only hours ago

http://support.iteadstudio.com/support/discussions/topics/11000011607


Your copy of IteadLib Arduino Nextion Library code is viewable.  Review.

assuming b0 press activates and b0 release deactivates

Button b0 needs to be defined properly param for (0,1,"b0")

needs to be accurate to what is in your HMI file

if you want your MCU to respond to a button press,

 - Nextion HMI button's Touch Press Event

    - checkbox for Send Component ID needs to be checked

if you want your MCU to respond to a button release,

 - Nextion HMI button's Touch Release Event

    - checkbox for Send Component ID needs to be checked


#include "Nextion.h"


// NexComponent mcusidename = NexComponent(pageno,.id,".objname");

NexButton MCUside_b0 = NexButton(0,1,"b0");


NexTouch  *nex_listen_list[] = {

  &MCUside_b0, NULL

};


void ButtonPressedCallback (void *ptr)

{

  // code for when button is pressed

}


void ButtonReleasedCallback (void *ptr)

{

  // code for when button is released

}


void setup(void)

{

  nexInit();

  MCUside_b0.attachPush(ButtonPressedCallback,&MCUside_b0);

  MCUside_b0.attachPop(ButtonReleasedCallback,&MCUside_b0);

}


void loop(void)

{

  nexLoop(nex_listen_list);

}


This is how to set up MCU to respond to press / release

Above skeleton code for Nextion side b0 only works when b0 definition is correct


// NexComponent mcusidename = NexComponent(pageno,.id,".objname");

NexButton MCUside_b0 = NexButton(0,1,"b0");


Such a declaration only works for button if

 - page number is 0

 - component .id attribute is 1

 - component .objname attribute is b0

ALELUIA .... NOW I UNDERSTAND ... THANK YOU ...

Login or Signup to post a comment