LED Controller, some small bugs!

Hi all, im having some slight issues with my program which im guessing is software related. Im using a arduino pro micro 5V to control my LED fixture i built but im having some small problems with some alarms aswell as comparing startup values.

The full program can be found at http://rugland.se/ledcontroller.html (its the v2.0 sketch) A report is also available there for the LED fixture i built.

When starting up the led fixture the program automatically gets the current time from my DS3231, it then starts the alarms aswell as comparing the Alarm times to see if any of the 5 PWM's should be ON.

The problems im having is that when starting the program for instance at 20.00 in the evening (i got some other alarm times saved in the EEPROM than the ones in the sketch) PWM 1 and PWM 2 is supposed to be ON and the rest OFF, but many times ALL PWM channels except PWM 4 is OFF (And PWM 4 shouldnt even be on at that time).

Problems/bugs:

  1. Is there posssible a error when comparing the values in the "AlarmCheck" function which im not aware off which makes the PWM4 to be ON but the PWM1 and PWM2 to be off (when it should be the opposite) ?

  2. Im using the timerOnce function to Dimmer the PWM's, but when the PWM has reached the End value the last alarm seems still be there, why is this? (Im able to see the amount of alarms on my LCD by the Alarm.count() function). Does "todays" alarm.repeat still linger until the next day ?

  3. Im using both the lcd.nodisplay aswell as putting the LCD backlight VCC to zero to be able to close down the LCD when not using it (ive tried using both one at a time as well) since i dont want the backlight on when im not using the display, but sometimes when it powers up again when moving the potentiometer or pushing the button there is not text, only backlight. Anyone knows why?

Alot of code but would be helpful if anyone could give any tips on the bugs ive encountered, maybe im implementing something wrong ?

thx for any help or improvements!

The full program can be found at LEDController (its the v2.0 sketch)
A report is also available there for the LED fixture i built.

When starting up the led fixture the program automatically gets the current time from my DS3231, it then starts the alarms aswell as comparing the Alarm times to see if any of the 5 PWM’s should be ON.

The problems im having is that when starting the program for instance at 20.00 in the evening (i got some other alarm times saved in the EEPROM than the ones in the sketch) PWM 1 and PWM 2 is supposed to be ON and the rest OFF, but many times ALL PWM channels except PWM 4 is OFF (And PWM 4 shouldnt even be on at that time).

The full program can be found there, except that you’ve made some changes.

And you want us to help you blindly fix your code? I think I’'l pass, unless you post YOUR code.

If you have an RTC, there really is no reason not to just do stuff based on what time it is. The time alarms library is not really necessary.

Sry! It wasnt possible to fit the whole code into the post. The code is the most recent version im using atm! Except that there are other values saved which im loading from the EEPROM.

So im guessing i can ask the questions like this instead:

  1. So u think i should skip using the time alarms library ? and just use some if statements when checking time isntead?

  2. Should i cast a byte to int (or vice versa) when comparing two values (where one is a byte and the other a int)?

  3. Timealarms library : When a daily alarm.repeat has gone off, when does the "previous" alarm actually dissapear, becuase when using the alarm.count function there is actually 2 Alarms after a alarm has been activated.

Thx for any help /Christian

  1. So u think i should skip using the time alarms library ? and just use some if statements when checking time isntead?

That's what I would do.

  1. Should i cast a byte to int (or vice versa) when comparing two values (where one is a byte and the other a int)?

Not necessary.

  1. Timealarms library : When a daily alarm.repeat has gone off, when does the "previous" alarm actually dissapear, becuase when using the alarm.count function there is actually 2 Alarms after a alarm has been activated.

Vague questions will be ignored. Questions about a specific block of code will get serious consideration.