Hello fellows a few week ago i build myself a LED Matrix with 140LEDs
So its working fine so far. Now i wanted to use that LED Matrix as a "wake up light". I mounted it on the wall and found the time and timealarm library.
My Problem is, that it isnt working as it should. If the alarm is only a few minutes or some hour later, then its working as it should. But if the alarm is something around 6 hours later, then i uploaded the code, then its not working any more.
Is there any problem with the code?
Here is my code, cant find the problem
The repeats function, is for increasing the brightness every 120secs. The first part, which turn the LEDs out if the alarm isnt triggered is necessary, because sometimes some LEDs start to light up.
/*
* TimeAlarmExample.pde
*
* This example calls alarm functions at 8:30 am and at 5:45 pm (17:45)
* and simulates turning lights on at night and off in the morning
* A weekly timer is set for Saturdays at 8:30:30
*
* A timer is called every 15 seconds
* Another timer is called once only after 10 seconds
*
* At startup the time is set to Jan 1 2011Â 8:29 am
*/
#include <Time.h>
#include <TimeAlarms.h>
#include "FastLED.h"
#define NUM_LEDS 140
const int dataline = 6;
CRGB leds[NUM_LEDS];
boolean alarm=false;
int counter=0;
void setup()
{
 Serial.begin(9600);
 LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
 alarm=false;
 setTime(14,27,0,13,1,16); // set time
 // create the alarms
 Alarm.alarmRepeat(14,27,1, MorningAlarm); // 8:30am every day
// Alarm.alarmRepeat(10,00,0,Ausschalten);Â // 10:00pm every day
Alarm.timerRepeat(120, Repeats);      // timer for every 15 seconds Â
}
void loop(){Â
}
// functions to be called when an alarm triggers:
void MorningAlarm(){
 alarm=true;
 counter=0;
Â
 Serial.println("Alarm: - turn lights off");
 for (int p=0;p< NUM_LEDS;p++){
  leds[p].maximizeBrightness();
  leds[p] = CRGB( 255/15, 69/15, 0);
  FastLED.show();}Â
}
void Ausschalten (){
for (int p=0;p< NUM_LEDS;p++){
leds[p] = CRGB::Black;Â
FastLED.show();}
alarm=false;
Â
}
void Repeats(){
 Â
 if (alarm=false){
   for (int p=0;p< NUM_LEDS;p++){
   leds[p] = CRGB::Black;Â
   FastLED.show();}
 Â
 }
 if (alarm=true and counter <15)
 {
  for (int p=0;p< NUM_LEDS;p++){
  leds[p] *= 2;
  FastLED.show();}
  counter=counter+1; }
  Â
}
greetings
Mirgus