Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple dimmers not working on Arduino UNO #5

Open
vibhoregit opened this issue Nov 30, 2024 · 0 comments
Open

Multiple dimmers not working on Arduino UNO #5

vibhoregit opened this issue Nov 30, 2024 · 0 comments

Comments

@vibhoregit
Copy link

vibhoregit commented Nov 30, 2024

When connecting multiple lamps, there is interference in brightness, changing the power of one lamp changes the other. Even two dimmer are not working properly. Refer the example below:
`
#include <RBDdimmer.h>

//#define USE_SERIAL SerialUSB //Serial for boards whith USB serial port
#define USE_SERIAL Serial
#define Ch0 3
#define Ch1 9
int ch_sel;
int ch_pow;
#define zerocross 2 // for boards with CHANGEBLE input pins
dimmerLamp dimmer0(Ch0);
dimmerLamp dimmer1(Ch1);
void setup() {
USE_SERIAL.begin(9600);
dimmer0.begin(NORMAL_MODE, ON); //dimmer initialisation: name.begin(MODE, STATE)
dimmer1.begin(NORMAL_MODE, ON);
USE_SERIAL.println("Lamp Controller - 1 Online");
}
void loop() {
if (USE_SERIAL.available()) {
char ch = USE_SERIAL.read();
if (ch == '#') {
ch_sel = USE_SERIAL.parseInt();
ch_pow = USE_SERIAL.parseInt();
if (ch_pow <= 100 && ch_pow >= 0) {
switch (ch_sel) {
case 0:
dimmer0.setPower(ch_pow);
break;
case 1:
dimmer1.setPower(ch_pow);
break;
default:
USE_SERIAL.println("Error 1");
break;
}
delay(20);
USE_SERIAL.print(ch_sel);
USE_SERIAL.print(',');
USE_SERIAL.println(ch_pow);
USE_SERIAL.flush();
}
else
USE_SERIAL.println("Error 2");
} else
{
USE_SERIAL.read();
}
}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant