Hi everyone, sorry if this is a dumb question but I am stuck and don’t know what else to try.
I bought an rbdimmer 1CH 4A module and I’m trying to control a desk lamp with my Arduino. I followed a tutorial I found online and copied the example code, but the dimmer does nothing at all. The lamp stays at full brightness no matter what value I send.
No error messages in Serial Monitor — the code compiles and uploads fine. I can see my Serial.println values changing but the lamp doesn’t respond.
I connected the ZC pin to pin 5 and the output pin to pin 6 on my Arduino. The AC side is wired correctly I think — LINE in, LOAD out to the lamp.
I am using Arduino IDE 2.3 and installed the RBDdimmer library from Library Manager.
Sorry for the basic question — this is my first electronics project. Any help would be really appreciated!
Hey Lucas, welcome to the forum!
A few things would help narrow this down. Could you post:
- Your exact Arduino board — is it an Uno, Nano, Mega, or something else? This matters a lot for the next question
- Your full sketch — the actual code you’re running, not a description of it
- Your pin connections — which exact pins for ZC, output, and how the AC side is wired
The reason I ask about the board specifically: on some Arduino models, not all pins support hardware interrupts. The ZC (zero-cross) pin needs to be on an interrupt-capable pin because the library uses attachInterrupt() internally.
Once you post the code and board info we can probably spot the issue pretty quickly.
Thank you Hank! Sorry I forgot to include the details.
My board is Arduino Uno (the original one with ATmega328P).
Here is my full code:
#include <RBDdimmer.h>
#define zeroCrossPin 5
#define dimmerPin 6
dimmerLamp dimmer(dimmerPin, zeroCrossPin);
void setup() {
Serial.begin(115200);
dimmer.begin(NORMAL_MODE, ON);
}
void loop() {
for (int i = 0; i <= 100; i++) {
dimmer.setPower(i);
Serial.println(i);
delay(50);
}
for (int i = 100; i >= 0; i--) {
dimmer.setPower(i);
Serial.println(i);
delay(50);
}
}
Pin connections:
- ZC pin from module → Arduino pin 5
- Output pin from module → Arduino pin 6
- AC side: LINE → module input, LOAD → lamp
The Serial Monitor shows values going 0, 1, 2… up to 100 and back down. But the lamp stays at full brightness the entire time. No flickering, no dimming, nothing.
I got no errors during compile or upload. What am I doing wrong?
Found it — this is an interrupt pin issue.
On the Arduino Uno, only pin 2 (INT0) and pin 3 (INT1) support external hardware interrupts. That’s it — no other pins work for attachInterrupt().
You have the ZC signal connected to pin 5, which is a regular digital I/O pin. The RBDdimmer library calls attachInterrupt() on the ZC pin to detect zero-cross events. Since pin 5 doesn’t support hardware interrupts, the interrupt never fires, the library never detects zero-cross, and the TRIAC never gets triggered. Result: lamp stays at full brightness (AC passes through uncontrolled).
The fix:
Move your ZC wire from pin 5 to pin 2. Then update your code:
#define zeroCrossPin 2 // must be pin 2 or 3 on Uno
#define dimmerPin 6 // output pin can be any digital pin
For reference, here are the interrupt-capable pins by board:
- Arduino Uno / Nano: pin 2 (INT0), pin 3 (INT1)
- Arduino Mega: pins 2, 3, 18, 19, 20, 21
- ESP32: any GPIO pin supports interrupts
For anyone finding this later: the output pin (dimmerPin) can be any digital pin — only the ZC pin has the interrupt requirement.
[SOLVED] It works!! Thank you very much for the help!
I moved the ZC wire from pin 5 to pin 2 and changed the code to #define zeroCrossPin 2 — now the lamp dims smoothly from 0 to 100 and back. Exactly what I wanted!
I feel a bit silly that it was just a wrong pin, but I had no idea that only certain pins support interrupts. The tutorial I followed didn’t mention this at all — it just said “connect ZC to any digital pin”.
Thank you Hank for asking the right questions and finding the problem so fast. And thanks rbdimmer team for the reference table — I bookmarked the hardware connection page for future projects.
This is a great community!