Light Dimming using Arduino and robotdyn AC dimmer for PWM

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;
  }
}

Thanks in advanced!

what light do you dim? is it dim-able?

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.

Both light have the same flickering problem

As @Juraj already asked are those specified as dimmable. If the manufacturer does not specifically say so, then they are probably not dimmable

it's not specified as dimmable but it does dim when we tried. The problem is that it flickers. Can't we make it work somehow?

Post a picture of your "magic" lamp.


Here's the photo of the grow light. Hoping that magic could work

it flickers because it is not dim-able

Get an RGB LED strip that fits the lamp housing and make a dimmable lamp.

You mean to replace the LED placed inside the grow light with RGB LED?

Is this for growing marihuana?

It's for onion hydroponics system

Can I use this but replace the button with the robotdyn AC dimmer? as I'd like it to dim automatically

I think you have to learn some Arduino basics in soft- as in hardware.

No ac dimmer needed. But it'll require hacking - and PWM and a switching transistor (or transistors).

[Hydroponic onions.]

1 Like

No. The robotdyn only works with AC, that LED strip is DC

1 Like

Ohh right since the LED requires 5V DC

Thanks I'll try it after I bought the LED strips

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.