Se rendre au contenu

Bienvenue !

Partagez et discutez du meilleur contenu et des nouvelles idées de marketing, développez votre profil professionnel et devenez ensemble un meilleur spécialiste du marketing.

S'inscrire

Vous devez être inscrit pour interagir avec la communauté.
Cette question a été signalée
781 Vues

Hi all,

I have an 8A RBDimmer that I'm using with an Arduino Nano clone board (ATMega328p with a CH340g USB-serial chip). I have a sketch running to gradually brighten a tungsten/incandescent bulb (not an LED, which I know can cause problems), and it is exhibiting weird behavior:


From 1% to 13% power, the bulb is lit at a constant brightness of about 60% (the brightness does not change between 1% and 14% power).

Then from 14% to 16% power, the bulb flickers at a high frequency (maybe 50 Hz or so).

Then from 16% to 17% power, the bulb turns on and off at a much lower frequency (maybe 5 Hz).


Again, this is a tungsten/incandescent bulb I'm using, not an LED.


It is also behaving weirdly above that (at 100% power it is not lighting LED bulbs at all), but I have a harder time deciphering that behavior.


The code I am running is pasted below. Can anyone possibly explain (and/or provide a fix for) the weird behavior I'm seeing?


Thank you.


#include <RBDdimmer.h> // RobotDyn AC Dimmer library


#define AC_LOAD 3 // DIM/PWM pin connected to the RobotDyn module

#define ZC_PIN 2 // Zero-cross pin from the RobotDyn module (wired to D2, but handled internally)


// Create dimmer object (older library: only takes 1 argument)

dimmerLamp dimmer(AC_LOAD);


void setup() {

Serial.begin(9600);


// Initialize dimmer (older library handles ZC internally)

dimmer.begin(NORMAL_MODE, OFF);

dimmer.setPower(0);


Serial.println("Starting 30-minute gradual brightening...");

}


void loop() {

const int startBrightness = 0; // Start at 18% because below 18% it flickers.

const int endBrightness = 100; // End at 100%

const unsigned long totalTime = 1UL * 30UL * 1000UL; // calculating total time in milliseconds of fadeup; minutes, seconds per minute, milliseconds per second

const int steps = 100; // 1% increments

unsigned long delayPerStep = totalTime / steps; // calculating milliseconds per step


// Gradually brighten

for (int brightness = startBrightness; brightness <= endBrightness; brightness++) {

dimmer.setState(ON);

dimmer.setPower(brightness); // Set brightness (0–100%)

Serial.print("Brightness: ");

Serial.print(brightness);

Serial.println("%");

delay(delayPerStep);

}


// Hold full brightness indefinitely

Serial.println("Reached full brightness. Holding...");

dimmer.setPower(100);

dimmer.setState(ON);


while (true) {

delay(1000); // keep AC dimmer timing active

}

}


Avatar
Ignorer

Votre réponse

Veuillez essayer de donner une réponse substantielle. Si vous voulez commenter la question ou la réponse, utilisez simplement l'outil de commentaire. Rappelez-vous que vous pouvez toujours réviser vos réponses - pas besoin de répondre deux fois à la même question. Aussi n'oubliez pas de voter - cela aide vraiment à sélectionner les meilleures questions et réponses !