#include #include "NexTouch.h" #include "Nextion.h" # const int relay1Pin = 9; const int relay2Pin = 8; const int relay3Pin = 7; const int relay4Pin = 6; const int relay5Pin = 5; const int relay6Pin = 4; const int relay7Pin = 3; const int relay8Pin = 2; const int relay9Pin = 1; const int NEOPIXEL_PIN = 26; NexButton b0 = NexButton(0, 1, "b0"); NexButton b1 = NexButton(0, 2, "b1"); NexButton b2 = NexButton(0, 3, "b2"); NexButton b3 = NexButton(0, 4, "b3"); NexButton b4 = NexButton(0, 5, "b4"); NexButton b5 = NexButton(0, 6, "b5"); NexButton b6 = NexButton(0, 7, "b6"); NexButton b7 = NexButton(0, 8, "b7"); NexButton b8 = NexButton(0, 9, "b8"); Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, 26, NEO_GRB + NEO_KHZ800); char buffer[100] = {0}; NexTouch *nex_listen_list[] = { &bo, &b1, &b2, &b3, &b4, &b5, &b6, &b7, &b8, NULL }; void boPopCallback(void*ptr){ uint32_t b0 = Serial.read(); if (b0 == 0) digitalWrite(relay1Pin, HIGH); delay(5000); else if (b0==0x01) digitalWrite(relay1Pin, LOW); } void setup(void) { pinMode(9,OUTPUT); pinMode(8,OUTPUT); pinMode(7,OUTPUT); pinMode(6,OUTPUT); pinMode(5,OUTPUT); pinMode(4,OUTPUT); pinMode(3,OUTPUT); pinMode(2,OUTPUT); pinMode(26,OUTPUT); } { nexInit(); b0.attachPop(boPopCallback, &b0); b1.attachPop(boPopCallback, &b1); b2.attachPop(boPopCallback, &b2); b3.attachPop(boPopCallback, &b3); b4.attachPop(boPopCallback, &b4); b5.attachPop(boPopCallback, &b5); b6.attachPop(boPopCallback, &b6); b7.attachPop(boPopCallback, &b7); b8.attachPop(boPopCallback, &b8); dbSerialPrintln("setup done") } void loop(void) { nexLoop(nex_listen_list); }