Guide: Arduino based LED controller for Current Satellite LED+ - Page 48 - The Planted Tank Forum
Reply
 
LinkBack Thread Tools Display Modes
post #706 of 716 (permalink) Old 07-04-2015, 12:31 AM
Algae Grower
 
PTrader: (0/0%)
Join Date: Feb 2014
Location: San Diego, CA
Posts: 38
Sweet! That's pretty cheap!! Thanks for the links and info! I'll look it over in more depth later.
Curt_Planted is offline  
Sponsored Links
Advertisement
 
post #707 of 716 (permalink) Old 12-09-2015, 09:10 PM
Algae Grower
 
Nathan Triplett's Avatar
 
PTrader: (0/0%)
Join Date: Dec 2015
Location: Portland, OR
Posts: 7
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(); }
Nathan Triplett is offline  
post #708 of 716 (permalink) Old 01-11-2016, 04:25 PM
Planted Tank Enthusiast
 
vanish's Avatar
 
PTrader: (4/100%)
Join Date: Apr 2014
Location: Longmont, CO
Posts: 960
Does anybody have one of these they want to sell? I'd love to have one for my tank. I have this light that does all these cool functions and don't use them!

I can handle programming just fine, but I'm terrible when it comes to assembling electronics.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
vanish is offline  
 
post #709 of 716 (permalink) Old 01-12-2016, 08:28 PM
Algae Grower
 
Nathan Triplett's Avatar
 
PTrader: (0/0%)
Join Date: Dec 2015
Location: Portland, OR
Posts: 7
If it's mostly the soldering that worries you, you can build a simple version of this with no soldering required at all.

Grab the Arduino board, wires, resistors, LED, and a breadboard:
https://www.adafruit.com/products/193

You can get just those bits individually, but this link has it all and is easy.

You need a clock. The ones from adafruit are kits, but you can get one all soldered together already here:
http://www.amazon.com/Holdding-AT24C32-Precision-Temperature-compensated-Oscillator/dp/B00LZCTMJM/
After that it's just a matter of connecting everything into the breadboard together which is way easier than you might think. You just use those jumper wires to connect it all. The end result won't be as slick and small as the ones people solder together, but it will work. Mine is still all on a breadboard at the moment as I keep putting off soldering it all together.

If you want to go this route and don't want to bother with the fancy display, I'm also happy to give you nice schematics on how to connect it all up on your breadboard.
Nathan Triplett is offline  
post #710 of 716 (permalink) Old 01-15-2016, 02:55 PM
Planted Tank Enthusiast
 
vanish's Avatar
 
PTrader: (4/100%)
Join Date: Apr 2014
Location: Longmont, CO
Posts: 960
Thanks Nathan. Does that RTC just plug in to the breadboard? I'm not terribly concerned with bundling it up pretty as it will be out of view anyway.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
vanish is offline  
post #711 of 716 (permalink) Old 04-30-2016, 08:16 PM
Newbie
 
PTrader: (0/0%)
Join Date: Apr 2016
Posts: 1
Anyone looked into incorporating an ambient light sensor, to automatically adjust the light relative to the room light?

My plan will be to get a Current Satellite LED+ Pro for now; and work out the fancy arduino stuff, if I can find the time.

My end goal would be to have the light in the tank always slightly higher than room light level, to give the tank that nice gentle glow. Also maybe tracking the mean light level in order to adjust the response of the ambient light sensor, with the goal of maintaining an average daily light dosage for the plants (let me know if that last part doesn't make sense, and I can try to explain what I am thinking better.)
aviphysics is offline  
post #712 of 716 (permalink) Old 08-02-2016, 03:32 AM
Newbie
 
PTrader: (0/0%)
Join Date: Jul 2016
Posts: 2
Quote:
Originally Posted by aviphysics View Post
Anyone looked into incorporating an ambient light sensor, to automatically adjust the light relative to the room light?

My plan will be to get a Current Satellite LED+ Pro for now; and work out the fancy arduino stuff, if I can find the time.

My end goal would be to have the light in the tank always slightly higher than room light level, to give the tank that nice gentle glow. Also maybe tracking the mean light level in order to adjust the response of the ambient light sensor, with the goal of maintaining an average daily light dosage for the plants (let me know if that last part doesn't make sense, and I can try to explain what I am thinking better.)
So, I believe I have currently wired up my arduino, but it does not appear to control the Satellite LED+ Pro I just purchased. LCD works fine, and I can see the LED flashing in the phone camera.

I'm going to grab a IR receiver, and do a dump of the codes. In the mean-time, maybe my LFS will let me try the rig on one of their Current LED+ to make sure it works. I think they're interested in me building them one XD.
trogdan is offline  
post #713 of 716 (permalink) Old 08-06-2016, 03:24 AM
Newbie
 
PTrader: (0/0%)
Join Date: Jul 2016
Posts: 2
Code for LED+ Pro

So, not sure why the sketch didn't work before, but the codes on the pro remote match the regular remote buttons, the functions have just changed. I did re-write the 3.6 version of the code so that it actually reflects what is on the remote, and this actually uses liquidcrystal_i2c, since it's easier to wire up.

Code:
///////////////////////////////////////////////////////////////////////
// Current Satellite LED+ Pro Controller  V3.6b+                     //
//   Indychus...Dahammer...Trogdan...mistergreen @ plantedtank.net   //
//   This code is public domain.  Pass it on.                        //
//   Confirmed on Arduino Duemilanove 1.0.6                          //
//   Req. Time, TimeAlarms, RTClib, IRremote                         //
///////////////////////////////////////////////////////////////////////
//
// This version uses Ken Shirriff's IRremote library to Rx/Tx the IR codes
// http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
// 
// This code does NOT use PIN 13 on the Uno, as do previous versions
// Instead PIN 3, which is a PWM pin, is used. So you'll need to connect
// your LED to PIN 3 instead of PIN 13 for it to work.

// Install LCD per instructions at http://learn.adafruit.com/character-lcds/overview

#include <Wire.h>
#include <RTClib.h>
#include <Time.h>
#include <TimeAlarms.h>
#include <IRremote.h>
//#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>

RTC_DS1307 RTC;
IRsend irsend;
//LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

/*********** BEGIN USER DEFINED VARIABLES ***********/
// DEBUG_IR adds the option to test the IR commands via the Arduino software's serial monitor
// You can send any value from 1 to 32 and it send the corresponding IR code
// The codes follow the remote controller, left to right, top to bottom
// e.g 1 = Orange, 2 = Blue, 21 = Moon1, etc
#define DEBUG_IR 0

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
// for the LED+ Pro Remote
unsigned int codeSetClock = 0x3AC5;
unsigned int codeOnTime = 0xBA45;
unsigned int codeOffTime = 0x827D;
unsigned int codePowerOnOff = 0x02FD;
unsigned int codeHour = 0x872D;
unsigned int codeMinute = 0x9A65;
unsigned int codeEnter = 0xA25D;
unsigned int codeResume = 0x22DD;
unsigned int codeOrange = 0x2AD5; 
unsigned int codeYellow = 0x1AE5;
unsigned int codeBlue = 0x926D; 
unsigned int codeViolet = 0x12ED; 
unsigned int codeRedUp = 0x0AF5;
unsigned int codeGreenUp = 0x8A75;
unsigned int codeBlueUp = 0xB24D;
unsigned int codeWhiteUp = 0x32CD;
unsigned int codeRedDown = 0x38C7;
unsigned int codeGreenDown = 0xB847;
unsigned int codeBlueDown = 0x7887;
unsigned int codeWhiteDown = 0xF807;
unsigned int codeM1Custom = 0x18E7;
unsigned int codeM2Custom = 0x9867;
unsigned int codeDaylight = 0x58A7;
unsigned int codeMoonlight = 0xD827;
unsigned int codeMoon1 = 0x28D7;
unsigned int codeMoon2 = 0xA857;
unsigned int codePartlyCloudy = 0x6897;
unsigned int codeDawnDusk = 0xE817;
unsigned int codeMostlyCloudy = 0x08F7;
unsigned int codeStorm1 = 0x8877;
unsigned int codeStorm2 = 0x48B7;
unsigned int codeEveningClouds = 0xC837;

void SetAlarms()
{
  // Set up your desired alarms here
  // The default value of dtNBR_ALARMS is 6 in Alarms.h.
  // This code sets 12 alarms by default, so you'll need to change dtNBR_ALARMS to 12 or more
  Alarm.alarmRepeat(7,00,0, DawnDusk);
  Alarm.alarmRepeat(9,00,0, PartlyCloudy);     // (HR,MIN,SEC,FUNCTION)
  Alarm.alarmRepeat(21,58,0, Daylight);
  Alarm.alarmRepeat(15,00,0, PartlyCloudy);
  Alarm.alarmRepeat(19,00,0, DawnDusk);
  //Alarm.alarmRepeat(21,00,0, Moon2);

  // Comment these out if you don't want the chance of a random storm each day
  Alarm.alarmRepeat(12,00,00, ThunderStorm);
  ThunderStorm();  // Sets up intial storm so we don't have wait until alarm time
}
/************* END USER DEFINED VARIABLES *************/

void setup()
{
  Wire.begin();
  RTC.begin();
  lcd.begin(20, 4);
  Serial.begin(9600);
  //Serial.println(freeRam());

  if (! RTC.isrunning()) { 
    Serial.println("RTC Error");
    RTC.adjust(DateTime(__DATE__, __TIME__));
  }  //Adjust to compile time


  setSyncProvider(syncProvider);     //reference our syncProvider function instead of RTC_DS1307::get()

  Alarm.timerRepeat(900, digitalClockDisplay);  // Display the time every 15 minutes
  digitalClockDisplay();
  SetAlarms();
  Serial.print("SRAM : ");          //un-comment these line to check available SRAM
  Serial.println(freeRam());
}   

void loop()
{
#ifdef DEBUG_IR 
  if (Serial.available() > 0) {
    delay(5); //Wait for transmission to finish
    CurrentCMDs(SerialReadInt());
  }
#endif
  Alarm.delay(100); 
  // Service alarms & wait (msec)
  lcdClockDisplay();
}

time_t syncProvider()
{
  //this does the same thing as RTC_DS1307::get()
  return RTC.now().unixtime();
}

void ThunderStorm ()
{ 
  // Schedules a storm between 1 & 9 in the evening
  // It sets Storm2, followed by Cloud2 or DawnDusk or Moon2, depending on when the storm is over
  randomSeed(analogRead(randAnalogPin));  // Generate random seed on unused pin
  byte RH = random(23);                   // Randomizer for thunderstorm
  byte RM = random(59);
  byte RS = random(59);
  byte TSDurationH = random(2);
  byte TSDurationM = random(59);

  if (RH <= 12)
  {
    Serial.println("No storm today");
    lcd.setCursor(0,1);
    lcd.print("No storm today");
    return;
  }

  if (RH > 12)                             // If random value is after 1 pm, allow storm
  {
    Alarm.alarmOnce(RH,RM,RS,Storm2);
    Serial.print("Next Storm: ");
    Serial.print(RH);
    printDigits(RM);
    printDigits(RS);
    Serial.print("   ");
    Serial.print("Duration = ");
    Serial.print(TSDurationH);
    printDigits(TSDurationM);
    Serial.println();
    lcd.setCursor(0,1);
    lcd.print("Next Storm: ");
    lcdHRdigits(RH);
    lcdDigits(RM);
  }

  if ((RH + TSDurationH) < 19)   // Return to Cloud2 if storm ends between 1-7pm
  {
    Alarm.alarmOnce((RH + TSDurationH),(RM + TSDurationM),RS,PartlyCloudy);
  }
  else if ((RH + TSDurationH) < 21)  // Return to DawnDusk if storm ends between 7-9pm
  {
    Alarm.alarmOnce((RH + TSDurationH),(RM + TSDurationM),RS,DawnDusk);
  }
  else                                       // Return to Night2 if storm ends after 9pm
  {
    Alarm.alarmOnce((RH + TSDurationH),(RM + TSDurationM),RS,Moon2);
  }
}


void digitalClockDisplay()          // Digital clock
{ 
  Serial.print("Time = ");
  Serial.print(hour());
  printDigits(minute());
  printDigits(second());
  Serial.println(); 
}


void lcdClockDisplay()  
{
  lcd.setCursor(0,0);
  lcdHRdigits(hour());
  lcdDigits(minute());
}

void printDigits(int digits)        // Add :
{
  Serial.print(":");
  if(digits < 10)
    Serial.print('0');
  Serial.print(digits);
}

void lcdDigits(int digits)        // Add :
{
  lcd.print(":");
  if(digits < 10)
    lcd.print('0');  
  lcd.print(digits);
}
void lcdHRdigits(int HRdigits)        // Preface hour with 0
{
  if(HRdigits < 10)
    lcd.print('0');  
  lcd.print(HRdigits);
}

#ifdef DEBUG_IR
int SerialReadInt()
{
  int i, numAva;
  char inBytes[3];                  // Array to hold the bytes
  char * inBytesPtr = &inBytes[0];  // Pointer to the first element of the array

  numAva = Serial.available();    // Read number of input bytes
  if (numAva > 2)
    numAva = 2;                   // Only allow 2 characters to prevent overflow

  for (i=0; i<numAva; i++)        // Load input bytes into array
    inBytes[i] = Serial.read();
  inBytes[i] =  '\0';             // Put NULL character at the end
  return atoi(inBytesPtr);        // Call atoi function and return result
}

void CurrentCMDs (int cmd)
{
  switch (cmd)
  {
  case 1:
    SetClock();
    break;
  case 2:
    OnTime();
    break;
  case 3:
    OffTime();
    break;
  case 4:
    PowerOnOff();
    break;
  case 5:
    Hour();
    break;
  case 6:
    Minute();
    break;
  case 7:
    Enter();
    break;
  case 8:
    Resume();
    break;
  case 9:
    Orange();
    break;
  case 10:
    Yellow();
    break;
  case 11:
    Blue();
    break;
  case 12:
    Violet();
    break;
  case 13:
    RedUp();
    break;
  case 14:
    GreenUp();
    break;
  case 15:
    BlueUp();
    break;
  case 16:
    WhiteUp();
    break;
  case 17:
    RedDown();
    break;
  case 18:
    GreenDown();
    break;
  case 19:
    BlueDown();
    break;
  case 20:
    WhiteDown();
    break;
  case 21:
    M1Custom();
    break;
  case 22:
    M2Custom();
    break;
  case 23:
    Daylight();
    break;
  case 24:
    Moonlight();
    break;
  case 25:
    Moon1();
    break;
  case 26:
    Moon2();
    break;
  case 27:
    PartlyCloudy();
    break;
  case 28:
    DawnDusk();
    break;
  case 29:
    MostlyCloudy();
    break;
  case 30:
    Storm1();
    break;
  case 31:
    Storm2();
    break;
  case 32:
    EveningClouds();
    break;
  default:
    Serial.println("Invalid Choice");
  }
}
#endif

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);
  }

  Serial.println(sMessage);  // Print message
  lcd.setCursor(6,0);
  lcd.print(sMessage);
  for(byte i = sizeof(sMessage); i <= 14; i++)
    lcd.print(" ");
  digitalClockDisplay();
}

void SetClock()
{
  SendCode(codeSetClock, 2, "SetClock");
}

void OnTime()
{
  SendCode(codeOnTime, 2, "OnTime");
}

void OffTime()
{
  SendCode(codeOffTime, 2, "OffTime");
}

void PowerOnOff()
{
  SendCode(codePowerOnOff, 1, "Power On/Off");
}

void Hour()
{
  SendCode(codeHour, 2, "Hour");
}

void Minute()
{
  SendCode(codeMinute, 2, "Minute");
}

void Enter()
{
  SendCode(codeEnter, 2, "Enter");
}

void Resume()
{
  SendCode(codeSetClock, 2, "Resume");
}

void Orange()
{
  SendCode(codeOrange, 2, "Orange");
}

void Yellow()
{
  SendCode(codeYellow, 2, "Yellow");
}

void Blue()
{
  SendCode(codeBlue, 2, "Blue");
}

void Violet()
{
  SendCode(codeViolet, 2, "Violet");
}

void RedUp()
{
  SendCode(codeRedUp, 1, "Red Up");
}

void GreenUp()
{
  SendCode(codeGreenUp, 1, "Green Up");
}

void BlueUp()
{
  SendCode(codeBlueUp, 1, "Blue");
}

void WhiteUp()
{
  SendCode(codeWhiteUp, 1, "White Up");
}

void RedDown()
{
  SendCode(codeRedDown, 1, "Red Down");
}

void GreenDown()
{
  SendCode(codeGreenDown, 1, "Green Down");
}

void BlueDown()
{
  SendCode(codeBlueDown, 1, "Blue Down");
}

void WhiteDown()
{
  SendCode(codeWhiteDown, 1, "White Down");
}

void M1Custom()
{
  SendCode(codeM1Custom, 2, "Custom Mix 1");
}

void M2Custom()
{
  SendCode(codeM2Custom, 2, "Custom Mix 2");
}

void Daylight()
{
  SendCode(codeDaylight, 2, "Daylight");
}

void Moonlight()
{
  SendCode(codeMoonlight, 2, "Moonlight");
}

void Moon1()
{
  SendCode(codeMoon1, 2, "Moonlight 1");
}

void Moon2()
{
  SendCode(codeMoon2, 2, "Moonlight 2");
}

void PartlyCloudy()
{
  SendCode(codePartlyCloudy, 2, "Partly Cloudy");
}

void DawnDusk()
{
  SendCode(codeDawnDusk, 2, "Dawn/Dusk");
}

void MostlyCloudy()
{
  SendCode(codeMostlyCloudy, 2, "Mostly Cloudy");
}

void Storm1()
{
  SendCode(codeStorm1, 2, "Thunderstorm 1");
}

void Storm2()
{
  SendCode(codeStorm2, 2, "Thunderstorm 2");
}

void EveningClouds()
{
  SendCode(codeEveningClouds, 2, "Evening Clouds");
}

int freeRam () {
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}
trogdan is offline  
post #714 of 716 (permalink) Old 01-25-2017, 12:27 PM
Planted Tank Obsessed
 
Vinster8108's Avatar
 
PTrader: (4/100%)
Join Date: Sep 2016
Location: Columbus, OH
Posts: 422
I just finished a very similar project using a raspberry pi. I like how everything is 100% customizable now, possibilities are endless:
https://www.plantedtank.net/forums/10...ir-remote.html

75g Tank Journal:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Forest's Edge:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Vinster8108 is offline  
post #715 of 716 (permalink) Old 06-06-2017, 12:28 AM
Newbie
 
PTrader: (0/0%)
Join Date: Jun 2017
Posts: 1
I have used this code to implement on an Adafruit feather HUZZAH (wifi). I have soldered the components to a feather wing proto board, and plan to have a case 3D printed (adafruit supplies the 3D print files). I will one day add a display, but I don't have the component yet, and having a status webpage is a good alternative. Apart from the status page, you can send it a command to change the light remotely. It gets the time from an NTP server. I will post when I have it cleaned up a bit and it's a bit more stable.

I have noticed that sometimes the light doesn't change, but the IR code has been sent. Is this why certain codes are sent twice? I was trying to figure out the meaning behind this part of SendCode function.

Thanks for posting this - it's great for this light. I was really frustrated that I couldn't use my regular wall timer when I upgraded to LED.

Liz
liz.eidsness is offline  
post #716 of 716 (permalink) Old 10-10-2020, 01:41 AM
Algae Grower
 
PTrader: (0/0%)
Join Date: Oct 2010
Location: Mississippi
Posts: 120
Blast from the past. Evening folks, was just looking through some old files, came across this code, and thought give a report. My light and Arduino controller are still going strong, 7 years later. I did have to replace the power supply on the light a months back, but other than that the setup has not missed a beat.
Dahammer is offline  
Reply

Tags
arduino, automation, current led+, diy, light controller

Quick Reply
Message:
Options

Register Now



In order to be able to post messages on the The Planted Tank Forum forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.

User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.

Password:


Confirm Password:
Email Address
Please enter a valid email address for yourself.

Email Address:
OR

Log-in










Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes
Linear Mode Linear Mode



Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

 
For the best viewing experience please update your browser to Google Chrome