Problem with my time alarm

Hello fellows :slight_smile: 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 :slight_smile:

@Mirgus, you really should have read the How to use this forum - please read post at the top of the index page and How to use this forum before posting.

ie Your code and any error messages should always be placed between code tags. Posting it inline as you have done makes it much harder to read or copy and paste for diagnosis.

It's still not too late to edit your post and do this. You'll make potential helpers much happier. :slight_smile:

Also, these:-

if (alarm=false)
if (alarm=true and counter <15)

should look like this:-

if (alarm==false)
if (alarm==true and counter <15)

Sorry :confused: didnt see the code option as i opened the topic.

Thx for your reply :slight_smile:

I forgot that "=" is just for declaration :frowning:

awkward that it worked sometimes

i will try it

Thanks :slight_smile:

Mirgus:
Sorry :confused: didnt see the code option as i opened the topic.

Thx for your reply :slight_smile:

I forgot that "=" is just for declaration :frowning:

Thanks :slight_smile:

"=" is not just for declaration.

@Mirgus, thanks for editing and adding the code tags. Appreciated. :slight_smile:

I meant its not used as "equal".

I will reply if that fixed the problem. I will set an alarm this evening and will look if its worked :slight_smile:

Thanks for the fast replies :slight_smile:

Thanks for your help :slight_smile: Working like a charm :slight_smile:

Mirgus:
Thanks for your help :slight_smile: Working like a charm :slight_smile:

Excellent. A nice easy fix. :slight_smile: