Closed mavoIn closed 11 months ago
the variables are all mixed up in your code
const byte signal01Pins[] = { 11, 10, 9, 8 }; // Pins
RoxLed signalLeds[sizeof(signal01Pins)];
void setup() {
// setup leds for switches
for (byte i = 0; i < sizeof(signal01Pins); i++) {
signalLeds[i].begin(signal01Pins[i]);
signalLeds[i].setMode(ROX_DEFAULT);
}
signalLeds[0].on();
signalLeds[1].on();
// etc
}
Also i would avoid the use of sizeof and instead define the number of pins
#define TOTAL_PINS 4
const byte signal01Pins[TOTAL_PINS] = { 11, 10, 9, 8 }; // Pins
RoxLed signalLeds[TOTAL_PINS];
void setup() {
// setup leds for switches
for (byte i = 0; i < TOTAL_PINS; i++) {
signalLeds[i].begin(signal01Pins[i]);
signalLeds[i].setMode(ROX_DEFAULT);
}
signalLeds[0].on();
signalLeds[1].on();
// etc
}
Hi, sorry for mixing two sketches... Copy and paste mistake! With your code example and some trouble shooting it works.
First i had to add a led.update() in the loop function to activate the output.
Secondly i had to invert my led on/off logic because my LOW/HIGH is inverted. Before using your lib i used MobaTools. There's an invert function while attaching the leds: MobaTools > SoftLed
Would you like to add this function to your LED as well? It makes the lib more flexible. If not, i hope ist okay to fork you lib locally?
Thanks you very much for all your help!
You can fork it if you want i'll add a reverse option since it should have been added
version 1.7.1 has led reverse polarity for RoxLed
hello neroroxxx,
thank you very much for adding reverse polarity in your last version.
unfortunaltelly its not working during setup (). Later on in the loop () it's working correctly. Here is my setup code:
// setup leds for signal 01
for (byte i = 0; i < SIGNAL01_TOTAL_PINS; i++) {
signalLeds[i].begin(signal01Pins[i]);
signalLeds[i].setMode(ROX_DEFAULT);
signalLeds[i].reversePolarity(true);
Serial.println(signalLeds[i].getPolarity());
signalLeds[i].off(); // all leds off
}
signalLeds[0].on(); // first led on
Do you have an hint? Thx a lot. Best mavoIn
version 1.7.2 has a fix for this, you could also just turn the led on the off inside the loop for now.
You can also now reverse the polarity in the begin method.
// setup leds for signal 01
for (byte i = 0; i < SIGNAL01_TOTAL_PINS; i++) {
// add true after the pin number to reverse the polarity at boot
signalLeds[i].begin(signal01Pins[i], true);
signalLeds[i].setMode(ROX_DEFAULT);
// reversePolarity is not longer needed during setup, however you can still
// use it during the loop code
// signalLeds[i].reversePolarity(true);
Serial.println(signalLeds[i].getPolarity());
signalLeds[i].off(); // all leds off
}
signalLeds[0].on(); // first led on
Now it works as expected. Thx
Hi, i guess its a newbie alike question. Your examples only explain setting up one led. Unfortunately i am not able to setup multiple leds.
Thank you very much for your advice.