The Planted Tank Forum banner

Guide: Arduino based LED controller for Current Satellite LED+

174K views 715 replies 69 participants last post by  Dahammer 
#1 · (Edited)
So I made an off-hand comment in one of Current USA's threads last night about an Arduino controller for their LED+ freshwater fixture. In the 12 or so hours since posting that, I have probably received a dozen PM's requesting code, IR protocol, sketches, or other information. Instead of responding to each request for information separately, it became obvious that I just needed to put together a thread for my project. This is that thread.

First, a disclaimer. While I'm not your average DIY tinkerer, I'm also not an electronics expert. I'm a mechanical engineer by day, and like to think of myself as a modern mad scientist by night. If you decide to build your own controller based on this thread, be aware that you're on your own. That's not to say I won't help... I think open source is the way of the future and love to pass knowledge on. I just mean that if you burn up your Arduino, yourself, or your house, that it's on you.

I'm putting together a guide to follow along, but none of the steps should be considered the last step. The nice thing about Arduino is how easy it is to constantly modify your code and add features. Throughout this thread, I will periodically post my newest code so that you can upload it and get the newer features. If you're experienced with Arduino, feel free to hack my code apart and have your way with it.

This process should work for any light fixture with some tweaking!

I'm writing this step-by-step so hopefully anyone can follow along. The more Arduino users we have in the world, the better life can be for everyone! If you're new to Arduino, don't be overwhelmed... it's not as difficult as it seems at first glance. And if you're an old hand please don't bash my primitive coding too much!



Everything in this post should be considered open source and public domain. Feel free to use my code, distribute it, hack it up, whatever.
 
See less See more
#661 ·
and this text below (time alarms lib) in red is the number you change to increase time alarms correct? I increased to 25




Code:
//  TimeAlarms.h - Arduino Time alarms header for use with Time library

#ifndef TimeAlarms_h
#define TimeAlarms_h

#include <inttypes.h>

#include "Time.h"

#define dtNBR_ALARMS 25   // max is 255

#define USE_SPECIALIST_METHODS  // define this for testing
 
#663 ·
Here's the sketch that I use to set the time and date on my DS1307 RTC. This sketch was written by "Sink", a forum member here at PlantedTank.net This sketch pulls the time directly from your PC, and loads it directly to the clock chip. There's no need to adjust any variables, just open the sketch, & hit the upload button. Easy Peasy:)

Code:
 /*
 * Name:    timeset.pde
 * Author:    User "sink" at plantedtank.net forums
 * URL:        http://bitbucket.org/akl/tank-control
 *
 * This code sets the time on a DS1307 RTC chip attached to an Arduino
 * microcontroller board.  The time is set to the system time when the
 * sketch was compiled (using preprocessor macros), so make sure that:
 *
 *     1. Your system (PC) time is accurate.
 *     2. You recompile the sketch and then upload immediately.
 *
 * The time is skewed forward some seconds to accomodate for compilation and
 * upload time.  If you find the time is consistently off by the same amount,
 * you can modify the adjustment constant below.
 *
 * This code requires the following libraries: Wire, Time, DS1307RTC
 *
 * The latest version of this code can always be found at above url.
 */

/*
 * Copyright (c) 2011, User "sink" at plantedtank.net forums
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.

 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.  
 */

#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>

/*
 * Time adjustment forward in seconds.  Used to compensate for
 * compilation/upload time.
 */
const int kAdjustment = 25;

/*
 * Utility function for pretty digital clock time output
 * From example code in Time library -- author unknown
 */
void printDigits(int digits) {
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

/*
 * Display time
 * Adapted from example code in Time library -- author unknown
 */
void digitalClockDisplay() {
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.print(" ");
  Serial.print(month());
  Serial.print("/");
  Serial.print(day());
  Serial.print("/");
  Serial.print(year()); 
  Serial.println(); 
}

void setup() {

  // convert compilation time and set system clock
  char const *date = __DATE__;
  char const *time = __TIME__;
  int sec, min, hour, day, month, year;
  
  char s_month[5];
  static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
  sscanf(date, "%s %d %d", s_month, &day, &year);
  month = (strstr(month_names, s_month)-month_names)/3;
  sscanf(time, "%d:%d:%d", &hour, &min, &sec);

  setTime(hour, min, sec, day, month+1, year);
  adjustTime(kAdjustment); // crude fwd correction
  time_t t = now();

  // set RTC
  RTC.set(t);

  Serial.begin(115200);
}

void loop () {
  digitalClockDisplay();  
  Serial.println(); 
  delay(1000);
}
 
#666 ·
Here's the sketch that I use to set the time and date on my DS1307 RTC. This sketch was written by "Sink", a forum member here at PlantedTank.net This sketch pulls the time directly from your PC, and loads it directly to the clock chip. There's no need to adjust any variables, just open the sketch, & hit the upload button. Easy Peasy:)
Hmm. I tried this code today, and I can't get it to compile and verify.

At first, it complained about RTC.set not being defined, but then I realized I needed to add the libraries from the link in the code. (in particular, ds1307rtc)

So I added the libraries and restarted the IDE, and now it's giving me a bunch of errors from within the ds12307rtc library:

Code:
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Mac OS X), Board: "Arduino Uno"
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp: In static member function 'static void DS1307RTC::read(tmElements_t&)':
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:56: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:62: error: 'class TwoWire' has no member named 'receive'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:63: error: 'class TwoWire' has no member named 'receive'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:64: error: 'class TwoWire' has no member named 'receive'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:65: error: 'class TwoWire' has no member named 'receive'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:66: error: 'class TwoWire' has no member named 'receive'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:67: error: 'class TwoWire' has no member named 'receive'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:68: error: 'class TwoWire' has no member named 'receive'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp: In static member function 'static void DS1307RTC::write(tmElements_t&)':
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:74: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:76: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:77: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:78: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:79: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:80: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:81: error: 'class TwoWire' has no member named 'send'
/Users/kman/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.cpp:82: error: 'class TwoWire' has no member named 'send'
 
#676 ·
A great thread, but I'm only about half way through reading the whole thing. I have a quick question:

I only want to control my SAT+, this is the guide for me, right?

I have read a lot of the other arduino threads and they all seem to include things such as dosing pumps. I don't want anything aside from lighting control at the moment.
 
#682 · (Edited)
New member here. I applaud all involved with this controller build. You have done an exceptional job !
I am currrently trying this build out for the Sat+, but I'm having problems compiling the sketch...
I'm using Ardunio ver 1.06 now as the newest ver. gave to many errors.
This is what my error report says:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
test4.1.ino:36: error: 'IRsend' does not name a type
test4.1.ino: In function 'void SendCode(int, byte)':
test4.1.ino:276: error: 'irsend' was not declared in this scope

I have tried compiling all versions from 3.7 to 4.1, and get same compiling errors in all of them. I am no coder, and google search has turned up no help to me. Would there be an issue with the irsend.h file? something I need to change? There is just way to much informaton here for me to find/remember and impliment.

Im using all library files from kman's great writeup on page 44.

If anyone could help or shed some light on my problem, my fish and I would be extremely greatfull . :icon_smil

I am using the OSEPP UNO R3 plus board.
 
#683 ·
I know I just PM'd this, but just to make sure, all your libraries are in the right place?

On my Windows 7 (64bit) laptop, my libraries are here:



EDIT:

Also, you say you are running "4.1" but are you running the modified 4.1 that is pasted in my thread on page 44? I can't recall if there is a significant difference, but that would certainly reduce one variable. The code is in my post, and starts off with "Current Satellite LED+ Controller V4.1 - MODIFIED FOR KMAN v2".

EDIT 2:

Make sure your IR LED is on the right pin. I think it's discussed in the post, but there are options for Mega and options for Uno. Make sure both the code, and the pin, are correct for the Uno.
 
#684 ·
Yes, my library location is same as yours :icon_smil
and yes, using this: "Current Satellite LED+ Controller V4.1 - MODIFIED FOR KMAN v2".

I am only using these librarys:
DS1307RTC
Iremote
LiquidCrystal
RTClib
Time
TimeAlarms
Dallas Temperature
OneWire
Do I need the others that you have showing?
/edit
are you saying that the ir led needs to be on the board atm?
/edit 2
I have nothing hooked to the uno right now..just my usb cable. I will feel pretty stupid if it has to be connedted to everyhing right now...
 
#685 ·
Ok, have the resistor/led hooked to uno on pin 3 and grd..looking better ;)

now, just have this error message:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
test41.ino: In function 'void SendCode(int, byte)':
test41:276: error: 'class IRsend' has no member named 'sendNEC'
 
#694 ·
Oh, wow, that's good to know.

What's the link to the updated file? I'll edit my post, if I can, and add the new one with the version that works.

Or, yeesh, maybe I should just package up all the libraries with the current, working versions and add that.
 
#698 ·
I never tried it. I have since moved over to the iAqua Lite for my smooth fading needs. :) (which borrowed Curt's crossfade code, IIRC)

Now I have to decide if I'm going to sell my two controllers off, or break them down to play with on other projects...
 
#702 ·
Another noob here.

Huge thanks for all the work done here. This is a fantastic project and something that pushed me into trying out the Arduino. I've been interested in it for years, but had no suitable project to try.

Now my problem:

I've got everything up and running with the version 3.6 sketch and a 16x2 LCD.

I'd like to get up to speed on the newer 4.1 based sketches, but it won't compile for me. I've gone over my libraries a few times to see if there was anything missing, but haven't had time to really dig into the problem. Here's the error:
Code:
 Arduino: 1.6.4 (Windows 7), Board: "Arduino Uno"

light_cont_4_1:59: error: variable 'arrCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
light_cont_4_1:94: error: 'prog_char' does not name a type
light_cont_4_1.ino: In function 'void SendCode(int, byte)':
light_cont_4_1:264: error: 'arrMSG' was not declared in this scope
Multiple libraries were found for "IRremote.h"

 Used: C:\Users\gerwen\Documents\Arduino\libraries\IRremote

 Not used: C:\Program Files (x86)\Arduino\libraries\RobotIRremote

 Not used: C:\Program Files (x86)\Arduino\libraries\IRremote

Multiple libraries were found for "LiquidCrystal.h"

 Used: C:\Users\gerwen\Documents\Arduino\libraries\LiquidCrystal

 Not used: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal

variable 'arrCodes' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
Has anyone seen this and solved it?

It seems to have a problem with progmem dumping into flash. If i put a const on that, then the 'does not have a type' errors persist.

Any ideas where i should be looking?
 
#703 ·
I think my previous problem is still waiting mod approval to show. I've solved it.

Versions 4.1 and up of the controller sketches seem to require the Arduino Dev enviroment version 1.0.6, rather than the newer 1.6.x that I had been using. I haven't tested yet, but it compiled with no errors.

The older 3.6 (iirc) on the first page of the thread works just fine with the newer dev environment.

*edit in case my previous post never shows up*

I had the page one code version 3.6 working, but trying to compile 4.1, i threw a bunch of errors. The first of which complained about this line:

PROGMEM unsigned int arrCodes[32] = {0x3AC5, // 1 - Orange

saying that PROGMEM needed a CONST in order to push the array into flash

there were other errors, but that's the first one, so if you see something to that effect, check your environment version.
 
#704 ·
To answer the questions I saw earlier:

There is a 42 step resolution on the controller for each color and the remote gives a double command for each step. This is why you can see a noticeable jump when you press the button, but the fades are so much smoother in the automated lighting modes like cloudy day ect.

I did get my lighting control code working. I have since added in additional code for having a different lighting schedule on the weekends. I found on weekends I tended to sleep in and would wake up to the lights out and would also want to show off the tank later in the evening when I had company and the lights would be out. If anyone wants the latest code, let me know.

Has anyone directly hardware hacked this light? One of my connectors got screwed up and fried the lighting controller in the light but the LED's are still good and the wiring clearly labeled. I may save myself $100 and hack it with some directly arduino controlled regulators. If anyone has done it, any tips?
 
#705 · (Edited)
Has anyone directly hardware hacked this light? One of my connectors got screwed up and fried the lighting controller in the light but the LED's are still good and the wiring clearly labeled. I may save myself $100 and hack it with some directly arduino controlled regulators. If anyone has done it, any tips?
AFAICT the controller circuit is just like this (I assume there are programming differences.. ;)):
http://www.lightingever.com/44-key-...troller.html?gclid=CPLlg_OAv8YCFYQ8aQodkbIJ7g


Since the LED's are run in constant voltage mode "external drivers" are unnecessary and really wouldn't do..

The above pictured controllers do PWM chopping directly on the feed voltage.
You just need to make sure the I/O specs are OK..
AS to Aduino direct control.. This might help:
http://www.elcojacobs.com/using-shiftpwm-to-control-led-strips-with-arduino/
https://learn.adafruit.com/rgb-led-strips/usage
 
#707 ·
Hi to the thread (and forum in general).

First to the OP, thanks so much. This is awesome.
Second, I took your code and made my own version of it (attached below) which fades the lights smoothly on/off over a 24 hour period. And the fade up/down times, rates, and colors are all configurable. I thought I'd share the code in case it helps someone out.

My version is a stripped down as it comes. It doesn't have an LCD display (I may add that later) or IR receiver. It's just a 24 hour fader.

I'm running this version, but will probably clean up the code some next time I have a chance to dig in. I'll add some more comments and explain whats going on if people want as well. Cheers and thanks again for the guide.

Code:
#include <Wire.h>
#include <RTClib.h>
#include <Time.h>
#include <TimeAlarms.h>
#include <IRremote.h>

RTC_DS1307 RTC;
IRsend irsend;

int postDelay = 100;         // Delay after codes are sent
int randAnalogPin = 0;       // This needs to be set to an unused Analog pin, Used by ThunderStorm()

// Current Satellite+ IR Codes (NEC Protocol)
unsigned long codeHeader = 0x20DF; // Always the same

// Remote buttons listed left to right, top to bottom
unsigned int codeOrange = 0x3AC5;
unsigned int codeBlue = 0xBA45;
unsigned int codeRose = 0x827D;
unsigned int codePowerOnOff = 0x02FD;
unsigned int codeWhite = 0x1AE5;
unsigned int codeFullSpec = 0x9A65;
unsigned int codePurple = 0xA25D;
unsigned int codePlay = 0x22DD;
unsigned int codeRedUp = 0x2AD5;
unsigned int codeGreenUp = 0xAA55;
unsigned int codeBlueUp = 0x926D;
unsigned int codeWhiteUp = 0x12ED;
unsigned int codeRedDown = 0x0AF5;
unsigned int codeGreenDown = 0x8A75;
unsigned int codeBlueDown = 0xB24D;
unsigned int codeWhiteDown = 0x32CD;
unsigned int codeM1Custom = 0x38C7;
unsigned int codeM2Custom = 0xB847;
unsigned int codeM3Custom = 0x7887;
unsigned int codeM4Custom = 0xF807;
unsigned int codeMoon1 = 0x18E7;
unsigned int codeMoon2 = 0x9867;
unsigned int codeMoon3 = 0x58A7;
unsigned int codeDawnDusk = 0xD827;
unsigned int codeCloud1 = 0x28D7;
unsigned int codeCloud2 = 0xA857;
unsigned int codeCloud3 = 0x6897;
unsigned int codeCloud4 = 0xE817;
unsigned int codeStorm1 = 0x08F7;
unsigned int codeStorm2 = 0x8877;
unsigned int codeStorm3 = 0x48B7;
unsigned int codeStorm4 = 0xC837;

int wdticks = 0;
int rdticks = 0;
int bdticks = 0;
int gdticks = 0;
int wuticks = 0;
int ruticks = 0;
int buticks = 0;
int guticks = 0;


void SetAlarms()
{
  
  Alarm.alarmRepeat(6 ,0,0,MorningR);
  Alarm.alarmRepeat(8 ,0,0,MorningG);
  Alarm.alarmRepeat(9 ,0,0,MorningW);
  Alarm.alarmRepeat(9,50,0,MorningB);
  
  Alarm.alarmRepeat(17 ,0,0,EveningG);
  Alarm.alarmRepeat(18 ,0,0,EveningW);
  Alarm.alarmRepeat(19 ,0,0,EveningR);
  Alarm.alarmRepeat(19 ,0,0,EveningB);  

  Alarm.timerRepeat(15,timeNow);
  
}

void MorningW(){  Ramp(10800,43,WhiteUp, wuticks ); }
void MorningR(){  Ramp(18000,43,RedUp ,  ruticks ); }
void MorningB(){  Ramp(10800,43,BlueUp,  buticks ); }
void MorningG(){  Ramp( 7200,43,GreenUp, guticks ); }

void EveningW(){  Ramp(10800,43,WhiteDown, wdticks ); }
void EveningR(){  Ramp(10800,43,RedDown ,  rdticks ); }
void EveningB(){  Ramp(18000,43,BlueDown,  bdticks ); }
void EveningG(){  Ramp(10800,43,GreenDown, gdticks ); }

void Ramp(unsigned int seconds, unsigned int steps, void(*f)(), int & cntr ){
  Serial.println("starting Ramp");
  int interval = (int) ( 0.5 + float(seconds)/float(steps) );
  cntr = steps;
  Serial.print("enabling with interval");
  Serial.print(interval);
  Serial.print("and for");
  Serial.print(steps);
  Serial.print("steps");
  Serial.println();
  Alarm.timerRepeat(interval, f);
}

void setup()
{
  Wire.begin();
  RTC.begin();
  Serial.begin(9600);
  Serial.println("begin");

  if (! RTC.isrunning()) { 
    Serial.println("RTC Reset");
    timeNow();
    RTC.adjust(DateTime(__DATE__, __TIME__));
    timeNow();
  }  //Adjust to compile time  
  
  setSyncProvider(syncProvider);
  timeNow();
  
  SetAlarms();
 
}

void timeNow(){
  Serial.print(year(), DEC);
  Serial.print('/');
  Serial.print(month(), DEC);
  Serial.print('/');
  Serial.print(day(), DEC);
  Serial.print(' ');
  Serial.print(hour(), DEC);
  Serial.print(':');
  Serial.print(minute(), DEC);
  Serial.print(':');
  Serial.print(second(), DEC);
  Serial.println();
}

void loop()
{
  Alarm.delay(100); 
}

void SendCode (unsigned int code, byte numTimes, const char *sMessage){
  unsigned long irCode = (codeHeader << 16) + code; // Header is 2 bytes, shift all the way to left & add code to it
  
  for( int i = 0; i < numTimes; i++){
    irsend.sendNEC(irCode,32); // Send code
    Alarm.delay(postDelay);
  } 
}

void WhiteDown(){
  if( wdticks > 0 ){
    wdticks--;
    Serial.println("White Down");
    SendCode(codeWhiteDown, 1, "White Down");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}

void WhiteUp(){
  if( wuticks > 0 ){
    wuticks--;
    Serial.println("White up");
    SendCode(codeWhiteUp, 1, "White Up");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}

void RedDown(){
  if( rdticks > 0 ){
    rdticks--;
    Serial.println("Red Down");
    SendCode(codeRedDown, 1, "Red Down");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}

void RedUp(){
  if( ruticks > 0 ){
    ruticks--;
    Serial.println("Red up");
    SendCode(codeRedUp, 1, "Red Up");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}

void GreenDown(){
  if( gdticks > 0 ){
    gdticks--;
    Serial.println("Green Down");
    SendCode(codeGreenDown, 1, "Green Down");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}

void GreenUp(){
  if( guticks > 0 ){
    guticks--;
    Serial.println("Green up");
    SendCode(codeGreenUp, 1, "Green Up");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}

void BlueDown(){
  if( bdticks > 0 ){
    bdticks--;
    Serial.println("Blue Down");
    SendCode(codeBlueDown, 1, "Blue Down");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}

void BlueUp(){
  if( buticks > 0 ){
    buticks--;
    Serial.println("Blue up");
    SendCode(codeBlueUp, 1, "Blue Up");
  }else{
    Alarm.disable(Alarm.getTriggeredAlarmId());
    Alarm.free(Alarm.getTriggeredAlarmId());
    uint8_t x = Alarm.count();
    Serial.println(x);
  }
}


time_t syncProvider(){ return RTC.now().unixtime(); }
 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top