Hi! everyone. Can you please help with my code?
I'm using NodeMcu ESP8266 and AC Light Dimmer Module, 1 Channel, 3.3V/5V logic, AC 50/60hz, 220V/110V.
#include <RBDdimmer.h>//
//#define USE_SERIAL SerialUSB //Serial for boards whith USB serial port
#define USE_SERIAL Serial
#define outputPin 12
#define zerocross 5 // for boards with CHANGEBLE input pins
dimmerLamp dimmer(outputPin, zerocross); //initialase port for dimmer for ESP8266, ESP32, Arduino due boards
//dimmerLamp dimmer(outputPin); //initialase port for dimmer for MEGA, Leonardo, UNO, Arduino M0, Arduino Zero
int outVal = 0;
volatile bool intfired=false;
void setup() {
USE_SERIAL.begin(9600);
pinMode(zerocross, INPUT_PULLUP);
pinMode(outputPin, OUTPUT);
attachInterrupt(digitalPinToInterrupt(zerocross), handleInterrupt, CHANGE);
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
USE_SERIAL.println("Dimmer Program is starting...");
USE_SERIAL.println("Set value");
}
void printSpace(int val)
{
if ((val / 100) == 0) USE_SERIAL.print(" ");
if ((val / 10) == 0) USE_SERIAL.print(" ");
}
ICACHE_RAM_ATTR void handleInterrupt() {
intfired=true;
}
void loop() {
int preVal = outVal;
if (USE_SERIAL.available())
{
int buf = USE_SERIAL.parseInt();
if (buf != 0) outVal = buf;
delay(200);
}
dimmer.setPower(outVal); // setPower(0-100%);
if (preVal != outVal)
{
USE_SERIAL.print("lampValue -> ");
printSpace(dimmer.getPower());
USE_SERIAL.print(dimmer.getPower());
USE_SERIAL.println("%");
}
delay(50);
}
And, even though I put an "ICACHE_RAM_ATTR" or interrupt function. I still get these looping error.
load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
I'm still new at this. That's why I'm having trouble with this kind of problem and even in the technical stuff in Arduino. Hope you can help me. Thanks in Advance.