hola tal vez me puedas ayudar complementando el código o corrigiendo, necesito generar pulsos en 4 salidas del Arduino mega cada salida tiene 3 niveles diferentes de pulsos comandado cada uno con los botones de la pantalla Nextion que son 3 y 1 botón para apagar. Pero el botón de pagar no puedo configurarlo para que en los 4 tipos de salidas del Arduino mega 2560 cuando se este generando un pulso en una salida esta se pueda apagar en cualquier momento con un botón independiente de cada salida.
#include <Nextion.h>
NexButton bOff1 = NexButton(0, 2, "b0");
NexButton bOn1 = NexButton(0, 1, "b1");
NexButton bOn2 = NexButton(0, 3, "b2");
NexButton bOn3 = NexButton(0, 4, "b3");
NexButton bOff2 = NexButton(0, 5, "b4");
NexButton bOnn1 = NexButton(0, 6, "b5");
NexButton bOnn2 = NexButton(0, 7, "b6");
NexButton bOnn3 = NexButton(0, 8, "b7");
NexButton bOff3 = NexButton(0, 9, "b8");
NexButton bOnnn1 = NexButton(0, 10, "b9");
NexButton bOnnn2 = NexButton(0,11, "b10");
NexButton bOnnn3 = NexButton(0, 12, "b11");
NexButton bOff4 = NexButton(0, 13, "b12");
NexButton bOnnnn1 = NexButton(0, 14, "b13");
NexButton bOnnnn2 = NexButton(0, 15, "b14");
NexButton bOnnnn3 = NexButton(0, 16, "b15");
NexTouch *nex_listen_list[] = {
&bOff1,&bOn1, &bOn2,&bOn3,&bOff2,&bOnn1, &bOnn2,&bOnn3,&bOff3,&bOnnn1, &bOnnn2,&bOnnn3,&bOff4,&bOnnnn1, &bOnnnn2,&bOnnnn3, NULL
};
void btoff1(void *ptr);
void bton2(void *ptr);
void bton3(void *ptr);
void bton4(void *ptr);
void btof5(void *ptr);
void bton6(void *ptr);
void bton7(void *ptr);
void bton8(void *ptr);
void btoff9(void *ptr);
void bton10(void *ptr);
void bton11(void *ptr);
void bton12(void *ptr);
void btoff13(void *ptr);
void bton14(void *ptr);
void bton15(void *ptr);
void bton16(void *ptr);
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10,OUTPUT);
nexInit();
bOff1.attachPop(btoff1, &bOff1);
bOn1.attachPop(bton2, &bOn1);
bOn2.attachPop(bton3, &bOn2);
bOn3.attachPop(bton4, &bOn3);
bOff2.attachPop(btoff5, &bOff2);
bOnn1.attachPop(bton6, &bOnn1);
bOnn2.attachPop(bton7, &bOnn2);
bOnn3.attachPop(bton8, &bOnn3);
bOff3.attachPop(btoff9, &bOff3);
bOnnn1.attachPop(bton10, &bOnnn1);
bOnnn2.attachPop(bton11, &bOnnn2);
bOnnn3.attachPop(bton12, &bOnnn3);
bOff4.attachPop(btoff13, &bOff4);
bOnnnn1.attachPop(bton14, &bOnnnn1);
bOnnnn2.attachPop(bton15, &bOnnnn2);
bOnnnn3.attachPop(bton16, &bOnnnn3);
}
void loop() {
nexLoop(nex_listen_list);
}
void bton2(void*ptr) {
if (digitalRead (bton2)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(13, HIGH);
delay(800);
digitalWrite(13, LOW);
delay(200);
}
}
}
void bton3(void*ptr) {
if (digitalRead (bton3)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(13, HIGH);
delay(600);
digitalWrite(13, LOW);
delay(400);
}
}
}
void bton4(void*ptr) {
if (digitalRead (bton4)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(800);
}
}
}
void btoff1(void *ptr) {
digitalWrite(13, LOW);
}
void bton6(void*ptr) {
if (digitalRead (bton6)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(12, HIGH);
delay(800);
digitalWrite(12, LOW);
delay(200);
}
}
}
void bton7(void*ptr) {
if (digitalRead (bton7)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(12, HIGH);
delay(600);
digitalWrite(12, LOW);
delay(400);
}
}
}
void bton8(void*ptr) {
if (digitalRead (bton8)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(12, HIGH);
delay(200);
digitalWrite(12, LOW);
delay(800);
}
}
}
void btoff5(void *ptr) {
digitalWrite(12, LOW);
}
void bton10(void*ptr) {
if (digitalRead (bton10)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(11, HIGH);
delay(800);
digitalWrite(11, LOW);
delay(200);
}
}
}
void bton11(void*ptr) {
if (digitalRead (bton11)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(11, HIGH);
delay(600);
digitalWrite(11, LOW);
delay(400);
}
}
}
void bton12(void*ptr) {
if (digitalRead (bton12)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(11, HIGH);
delay(200);
digitalWrite(11, LOW);
delay(800);
}
}
}
void btoff9(void *ptr) {
digitalWrite(11, LOW);
}
void bton14(void*ptr) {
if (digitalRead (bton14)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(10, HIGH);
delay(800);
digitalWrite(10, LOW);
delay(200);
}
}
}
void bton15(void*ptr) {
if (digitalRead (bton15)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(10, HIGH);
delay(600);
digitalWrite(10, LOW);
delay(400);
}
}
}
void bton16(void*ptr) {
if (digitalRead (bton16)==LOW) {
for(int y=0; y<50; y++){
digitalWrite(10, HIGH);
delay(200);
digitalWrite(10, LOW);
delay(800);
}
}
}
void btoff13(void *ptr) {
digitalWrite(10, LOW);
}