hello everyone, hope you guys can help. have a problem with arduino program which should show data from nextion slider to arduino pin3 (PWM) value, everything from nextion should be correct .. please see arduino program please
greetings holmenshus
Arduino:
#include <Nextion.h>
const int pinLED = 3; //PWM pin
char buffer[100] = {0};
//Declare your Nextion objects , pageid, component id., comLedponent name
NexSlider h0 = NexSlider(0,1,"h0");
NexTouch *nex_listen_list[] = {
&h0,
NULL
};
void h0PopCallback(void *ptr){
//LED pwm fra nextion slider kan ikke få nogle værdier fra slider??
uint32_t number = 0;
h0.getValue(&number);
int value = map(number, 0,100,0,255);
analogWrite(pinLED, value);
memset(buffer, 0, sizeof(buffer));
itoa(value, buffer, 10);
// statusPWM.setText(buffer);
}
void setup() {
Serial.begin(9600);
pinMode(pinLED, OUTPUT);
nexInit();
h0.attachPop(h0PopCallback);
}
void loop() {
nexLoop(nex_listen_list);
}