Good day! I'm currently experienc problem in light dimming. The light dims fine in the two extremes. However, at the middle value of the potentiometer, the light keeps on flickering. What could be the problem? The code is as follows:
#include <RBDdimmer.h>//
//#define USE_SERIAL SerialUSB //Serial for boards whith USB serial port
#define USE_SERIAL Serial
#define outputPin 12
#define zerocross 2 // for boards with CHANGEBLE input pins
#define potPin A0 // define the input pin for potentiometer
//fix potentiometer issue
const int potMin = 79;
const int potMax = 804;
int potValue;
//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;
void setup() {
USE_SERIAL.begin(9600);
dimmer.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
}
void loop()
{
potValue = analogRead(potPin); // read potentiometer
correctValue();
outVal = map(potValue,22, 1023, 100, 0); // analogRead(analog_pin), min_analog, max_analog, 100%, 0%);
USE_SERIAL.print("potValue:");
USE_SERIAL.print(potValue);
USE_SERIAL.print(" ");
USE_SERIAL.print(outVal);
USE_SERIAL.println("%");
dimmer.setPower(outVal); // name.setPower(0%-100%)
}
void correctValue()
{
if(potValue <potMin)
{
potValue =potMin;
}
if(potValue >potMax)
{
potValue =potMax;
}
}
we're trying on 220V 9W but we plan to actually use it for Sansi T8 15W LED Grow Light Full Spectrum, Wattage: 15 W, Input Voltage / Frequency: AC 220V / 50HZ.