Guide: Arduino based LED controller for Current Satellite LED+ - Page 35
Planted Tank Forums
Your Tanks Image Hosting *Tank Tracker * Plant Profiles Fish Profiles Planted Tank Guide Photo Gallery Articles

Go Back   The Planted Tank Forum > Specific Aspects of a Planted Tank > DIY


Reply
 
Thread Tools Display Modes
Old 07-11-2014, 10:19 PM   #511
drftndakota
Newbie
 
PTrader: (0/0%)
Join Date: Jul 2014
Location: Missouri
Posts: 3
Default

Im curious if anyone is having trouble communicating with a new LED+ bar? have they changed the IR coding? i went back to the beginning to test for new ir codes but i am having trouble figureing out how to take the data from the serial monitor and turning that into the appropriate hex codes to test for a different coding. Just curious if anyone might be able to lend a hand on this. I can post a copy of the serial data if that is helpful.

Thanks
drftndakota is online now   Reply With Quote Quick reply to this message
Sponsored Links
Advertisement
 
Old 07-11-2014, 10:28 PM   #512
Linwood
Planted Tank Enthusiast
 
PTrader: (0/0%)
Join Date: Jun 2014
Location: Cape Coral, Florida
Posts: 519
Default

I don't know how old mine is (I bought it less than a month ago but... ).

I can provide my codes, however these are on Raspberry Pi using LIRC, so I'm not completely sure if they map to what you are doing, but I think they may.

This is more or less top to bottom left to right. I use M4 for "Off".

I guess there's no reason they might not have changed codes, though it would seem a bit silly as they'd have to reprogram that remote itself and keep two different part numbers, etc. There's no part number on mine but there is a V.1.0 on the remote itself.

Code:
          Orange                   0x3AC5
          Blue                     0xBA45
          RosePink                 0x827D
          Power                    0x02FD
          White                    0x1AE5
          FullSpectrum             0x9A65
          Purple                   0xA25D
          PlayStop                 0x22DD
          RedUp                    0x2AD5
          GreenUp                  0xAA55
          BlueUp                   0x926D
          WhiteUp                  0x12ED
          RedDown                  0x0AF5
          GreenDown                0x8A75
          BlueDown                 0xB24D
          WhiteDown                0x32CD
          M1                       0x38C7
          M2                       0xB847
          M3                       0x7887
          OffDim                   0xF807
          MoonIntense              0x18E7
          MoonFading               0x9867
          MoonFadingCloudy         0x58A7
          DawnGentleCloud          0xD827
          BrightWhiteRollingCloud  0x28D7
          CloudIntense             0xA857
          CloudGentle              0x6897
          CloudBright              0xE817
          RainIntense              0x08F7
          RainSlower               0x8877
          RainLow                  0x48B7
          GentleFade               0xC837
Linwood is offline   Reply With Quote Quick reply to this message
Old 07-11-2014, 10:46 PM   #513
drftndakota
Newbie
 
PTrader: (0/0%)
Join Date: Jul 2014
Location: Missouri
Posts: 3
Default

Is your device ID the same as the one in the original code?

Thanks for the quick reply my remote says V1.0 as well
so maybe I'm having issues elsewhere.. Since the codes i am using are the same as yours..
drftndakota is online now   Reply With Quote Quick reply to this message
Old 07-12-2014, 03:22 AM   #514
Linwood
Planted Tank Enthusiast
 
PTrader: (0/0%)
Join Date: Jun 2014
Location: Cape Coral, Florida
Posts: 519
Default

Quote:
Originally Posted by drftndakota View Post
Is your device ID the same as the one in the original code?

Thanks for the quick reply my remote says V1.0 as well
so maybe I'm having issues elsewhere.. Since the codes i am using are the same as yours..
Sorry, was at a ball game.

I didn't use the code in this thread, I recorded them with a different library, so I suspect it calls things something different. Here are the general settings I got:

Code:
  name  ledplus
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       8964  4453
  one           598  1633
  zero          598   521
  ptrail        588
  repeat        8971  2210
  pre_data_bits   16
  pre_data      0x20DF
  gap           107308
  toggle_bit_mask 0x0
Most of these are in decimal, but it put the "pre_data" in hex, which seems to match the OP's header.
Linwood is offline   Reply With Quote Quick reply to this message
Old 07-14-2014, 09:20 PM   #515
AnotherHobby
Wannabe Guru
 
AnotherHobby's Avatar
 
PTrader: (9/100%)
Join Date: Mar 2012
Location: Apple Valley, MN
Posts: 1,562
Default

Quote:
Originally Posted by drftndakota View Post
...i went back to the beginning to test for new ir codes but i am having trouble figureing out how to take the data from the serial monitor and turning that into the appropriate hex codes to test for a different coding...
This little sketch will spit IR HEX codes right into your serial monitor for you. It's super easy, and no need to "decode" or figure anything out.

Code:
#include <IRremote.h> // use the library
int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;
void setup()
{
  Serial.begin(9600); // for serial monitor output
  irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    Serial.println(results.value, HEX); // display it on serial monitor in hex
    irrecv.resume(); // receive the next value
  }  // Your loop can do other things while waiting for an IR command
}
AnotherHobby is online now   Reply With Quote Quick reply to this message
Old 07-23-2014, 08:03 PM   #516
drftndakota
Newbie
 
PTrader: (0/0%)
Join Date: Jul 2014
Location: Missouri
Posts: 3
Default

Thanks for those that helped. I tested my remote and all codes were the same. Somehow I ended up with a bad led went and picked up another and everything works perfect. Anyway i have been working with Curts siesta code i have added serial LCD support to save pins. There is also instructions to switch to a standard lcd breakout.. I have started to merge the random storm from the Indychus code into the sketch as well. currently this is all commented out as i have not had time to finish it. If you want CO2 support all you need is to uncomment that code and it should work..

if anyone wants to add to it or help getting the tstorms working i wouldnt be offended lol..

Just thought i could help out a little all the people that helped me get this started.


Code:
///////////////////////////////////////////////////////////////////
// Current Satellite LED+ Controller II V1.0                     //
//   An Adaptation of code originally by Indychus...Dahammer...  //
//   and mistergreen @ plantedtank.net                           //
//                                                               //
//   This code is public domain.  Pass it on.                    //
//   Confirmed on Arduino duemilanove                            //
//   Req. Time, TimeAlarms, IRremote                             //
//   Modified By Curt_Planted @ plantedtank.net to exclude all   //
//   external hardware, include new custom fade functions        //
//   and automatic timing                                        //
///////////////////////////////////////////////////////////////////
//
// 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 for the IR led. So you'll need to connect
// your IR LED to PIN 3 instead of PIN 13 for it to work. If you have a relay to control that 
// CO2 that is active low, off high, connect the control input to pin 4 and an indicator LED
// to pin 7. If your relay is active high, off low, connect it to pin 7.
// Connect the RTC (DS1307) SCL pin to A5 and SDA to A4
// This code also requires that you set the M4 preset of your light to all lights out
// if you use the sunset function for it to work properly. To do this dim all the colors
// of your lights down until they are all out then press and hold m4 for 5 seconds.
// change the lighting setting to another then press M4 to confirm, they will not flash
// to confirm the preset as usual at a no light level!

#include <IRremote.h>
#include <Wire.h>
#include "RTClib.h"
#include <SoftwareSerial.h>
#include <serLCD.h>
// #include <LiquidCrystal.h>

RTC_DS1307 rtc;
IRsend irsend;

int postDelay = 100;         
int randAnalogPin = 0;       // This needs to be set to an unused Analog pin, Used by ThunderStorm()
int CO2RelayPin = 4;
int CO2RelayLED = 7;

// Serial LCD 16x2 must be used connect your RX wire to pin 10 on the uno
SoftwareSerial SLCD(0,10);
serLCD lcd(10); 
// if you dont care about using so many pins or dont have a serial ready LCD comment out the above code as well as  #include <SoftwareSerial.h>, #include <serLCD.h>
// then uncomment the below command you will also need to remove the 9600 from the lcd.begin command 
// LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// 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;
//**********************************USER DEFINED VARIABLES************************************************
//******************define time in hours and minutes that are triggers************************************
 
//these are the times in order for the start of the different lighting stages for a siesta lighting schedule
//(fade up to accent color, full sunrise, sunset, sunrise, fade down to accent color, then sunset.)
//Without sacrificing full spectrum during the day it allows viewing in the accent color in the AM 
//and PM when you are more likely to be home! :) The code will automatically Dim the lights gradually 
// then bring them back up to the lighting for the initialization time in the setup loop

long LowSunriseH=5; //5:30am
long LowSunriseM=45;

long BrightenUpH=6; //5:45am
long BrightenUpM=0;

long SunriseH=10; //11am
long SunriseM=30;

long SunsetH=16;//345pm
long SunsetM=00;

long BrightenDownH=20;//845pm 
long BrightenDownM=30;

long LowSunsetH=21; //9pm
long LowSunsetM=0;

//byte TSDurationH;
//byte TSDurationM;



//time in minutes prior to lights turning on that co2 turns on
long CO2_Prestart=25;

//time in minutes before lights turn off that co2 turns off
long CO2_Prestop=20;

//time in minutes after the last sunset of the day that moonlighting is on. The moonlight will vary in brightness based
//on the day of the month, transitioning from brightest at the month start to dimmest at midmonth, then back to brightest
//by night end.
long Evening_Moon=60;

//  is the global delay between each code transmission (controls fade speed of all lighting changes) keep above 200 ms 
// or transmissions will fail. Each 1000 miliseconds adds about 3 minutes to a sunrise or sunset thus the default of 5000
// makes for a 15 minute sunrise and sunset.
// This variable is an input to all the light changing functions so you also can adjust them manually for each fade by inputing 
// them directly in the functions IE Sunrise(300);
int tstep1=5000; 

//these variables below store the number of steps each color is above completely dark for 
//your custom accent color. To get this number, set your tank to the lighting you want 
//then go through each color one by one and reduce the lighting to dark counting the number of 
//times you had to press the down button to do so. There are about 21 steps in brightness for the 
// remote for each color but they can vary with the length of the button press. This code uses the light's max 
// resolution of 42 steps so you will have to multiply the number of button presses by 2 with
// 42 being the max and zero meaning the led color is off. 

int Blue1=0;
int Red1=42;
int Green1=10;
int White1=6;

//You can also swap the CustomAccent() function in the main loop in for any of the other lighting changes
//or add your own if loops for additional lighting changes. The CustomAccent function has the
//format CustomAccent(Red, Green, Blue, White, Fade speed) See tstep above for fade speed input description
//and as long as you have initialized the counters to the current state, this will adjust the colors up or 
//down as needed to get the color you input. While it can be used for a sunrise or sunset it is better to
//use the built in functions to be sure the color counters do not drift over time due to missed transmissions.

/************* END USER DEFINED VARIABLES ****************************************************************/

int CondDelay=5; //time in seconds that time conditionals are true 

//this defines the time variables that will later store the above times converted to seconds in the day
//convert hours and minutes to seconds in the day
long LowSunriseT=(LowSunriseH*60+LowSunriseM)*60;

long BrightenUpT=(BrightenUpH*60+BrightenUpM)*60;

long SunsetT=(SunsetH*60+SunsetM)*60;

//long TStorm=(12*60+00)*60;

long SunriseT=(SunriseH*60+SunriseM)*60;

long BrightenDownT=(BrightenDownH*60+BrightenDownM)*60;

long LowSunsetT=(LowSunsetH*60+LowSunsetM)*60;

//These are your tracker variables for the current light levels of each color
int BlueNow;
int GreenNow;
int RedNow;
int WhiteNow;
int t;
long Time;
long Hour;
long Minute;
long Second;
long Tnow;
int Day;
//long WxNow;
//long WxEnd;


/*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);
  long WxNow=(RH*60+RM)*60;
  long WxEnd=((RM+TSDurationH)*60+(RM+TSDurationM))*60;
  
  if (RH <= 12)
    {
      Serial.println("No WX today");
      lcd.setCursor(7,1);
      lcd.print("No WX");
      return;
    }
      
  if (RH > 12)                             // If random value is after 1 pm, allow storm
    {
      
      //Serial.print("Next Storm: ");
      //Serial.print(RH);
      //Serial.print("   ");
      Serial.print("Duration = ");
      Serial.print(TSDurationH);
      Serial.println();
     lcd.setCursor(7,1);
     lcd.print("WX: ");
     lcd.print(RH);
     lcd.print(":");
     lcd.print(RM);}
     
      
      if ((RH + TSDurationH) < 19)   // Return to Cloud2 if storm ends between 1-7pm
        {Alarm.alarmOnce((RH + TSDurationH),(RM + TSDurationM),RS,Cloud2);}
      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 setup()
{
//*************************Initialization time needs to be set!***********************
 //this is the time when you power on the arduino or upload the code. For max precision
 //set this about a minute later than the time on your clock or phone etc, upload the code
 // then unplug the arduino and wait for a second before that time. the format of this is
 // setTime(hour,minute,second,day of month,month,year). Assure you start your arduino atleast
 // 5 minutes before or after any of the lighting change times to assure no conflicts 
 // between initialization and normal scheduled lighting changes.

  
 
/************* END USER DEFINED VARIABLES***************************************************************/


  Wire.begin();
  rtc.begin();
   
   Serial.begin(9600);
   //lcd.begin(9600);  with lcd.begin(16,2); for non Serial LCD
   lcd.begin(9600);
 //pinMode(CO2RelayPin, OUTPUT);
 //pinMode(CO2RelayLED, OUTPUT);
      //Serial.println(freeRam());
// Uncomment to reset time
//   rtc.adjust(DateTime(__DATE__, __TIME__));  //Adjust to compile time

//get current time from RTC and convert to seconds of the day, need to convert int from time to long! Lots of seconds in the day!

lcd.clear();
DateTime now = rtc.now();
Hour=(long) now.hour();
Minute=(long) now.minute();
Second=(long) now.second();
Day= now.day();
Tnow=(Hour*60+Minute)*60+Second;

lcd.setCursor(2,1);
lcd.print(Hour);
lcd.print(":");
lcd.print(Minute);
lcd.setBrightness(8);
//initialize color counters to full lighting to assure sunset is completed smoothly
RedNow=42;
GreenNow=42;
BlueNow=42;
WhiteNow=42;
//initialize co2 and night trackers
int initial_tstep=300;
if ((Tnow > LowSunriseT) && (Tnow < BrightenUpT)){
   //Serial.print("Tnow ");
   //Serial.println(Tnow);
   //Serial.print("LowSunriseT ");
   //Serial.println(LowSunriseT);
    lcd.setCursor(1,1);
    lcd.clearLine(1);
    lcd.print("Low Sunrise ");
   //digitalWrite(CO2RelayPin, LOW);
   //digitalWrite(CO2RelayLED, HIGH);
   //Serial.println("CO2 On");
   
   Sunset(initial_tstep);
   CustomAccent(Red1,Green1,Blue1,White1,initial_tstep);
   
   }
else if ((Tnow >= BrightenUpT) && (Tnow < SunsetT)){
   //Serial.print("Tnow ");
   //Serial.println(Tnow);
   //Serial.print("BrightenUpT ");
   //Serial.println(BrightenUpT);
      lcd.setCursor(1,1); 
      lcd.clearLine(1);
   lcd.print("Sunrise");
   RedNow=0;
   GreenNow=0;
   BlueNow=0;
   WhiteNow=0;
   //digitalWrite(CO2//digitalWrite(CO2RelayPin, LOW);
   //digitalWrite(CO2RelayLED, HIGH);
   //Serial.println("CO2 On");
   Sunrise(initial_tstep);
   }
   
   else if ((Tnow >= BrightenUpT) && (Tnow < SunsetT)){
   //Serial.print("Tnow ");
   //Serial.println(Tnow);
   //Serial.print("BrightenUpT ");
   //Serial.println(BrightenUpT);
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Sunrise");
  RedNow=0;
GreenNow=0;
BlueNow=0;
WhiteNow=0;
//digitalWrite(CO2//digitalWrite(CO2RelayPin, LOW);
//digitalWrite(CO2RelayLED, HIGH);
//   Serial.println("CO2 On");
   Sunrise(initial_tstep);
   }
else if ((Tnow >= SunsetT) && (Tnow < SunriseT)){
//Serial.print("Tnow ");
   //Serial.println(Tnow);
   //Serial.print("SunsetT ");
   //Serial.println(SunsetT);
   lcd.setCursor(1,1); lcd.clearLine(1);
  lcd.print("Sunset ");
  //digitalWrite(CO2RelayPin, HIGH); 
 //digitalWrite(CO2RelayLED, LOW);
   //Serial.println("CO2 Off"); 
   
Sunset(initial_tstep);
}
else if ((Tnow >= SunriseT) && (Tnow < BrightenDownT)){
  //Serial.print("Tnow ");
   //Serial.println(Tnow);
   //Serial.print("SunriseT ");
   //Serial.println(SunriseT); 
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Evening");
  //digitalWrite(CO2RelayPin, LOW);
  //digitalWrite(CO2RelayLED, HIGH);
  //Serial.println("CO2 On"); 
  RedNow=0;
GreenNow=0;
BlueNow=0;
WhiteNow=0;
   Sunrise(initial_tstep);}
else if ((Tnow >= BrightenDownT) && (Tnow < LowSunsetT)){
     //Serial.print("Tnow ");
   //Serial.println(Tnow);
   //Serial.print("BrightenDownT ");
   //Serial.println(BrightenDownT); 
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Simmer Down");
    //digitalWrite(CO2RelayPin, HIGH); 
    //digitalWrite(CO2RelayLED, LOW);
   //Serial.println("CO2 Off"); 
   
  Sunset(initial_tstep);
   CustomAccent(Red1,Green1,Blue1,White1,300);
   }
else if ((Tnow >= LowSunsetT) || (Tnow < LowSunriseT)){
 //Serial.print("Tnow ");
   //Serial.println(Tnow);
   //Serial.print("LowSunsetT ");
   //Serial.println(LowSunsetT);   
   lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Low Sunset");
    //digitalWrite(CO2RelayPin, HIGH); 
    //digitalWrite(CO2RelayLED, LOW);
   //Serial.println("CO2 Off"); ,
   Sunset(initial_tstep);
}

}

void loop(){
//get current time in seconds of the day, need to convert int from time to long! Lots of seconds in the day!!
//SunriseH 10:30 SunsetH 16 BrightenDownH 20:30 LowSunset 21:00

DateTime now = rtc.now();
Hour=(long) now.hour();
Minute=(long) now.minute();
Second=(long) now.second();
Tnow=(Hour*60+Minute)*60+Second;
lcd.setCursor(2,1);
     lcd.print(Hour);
     lcd.print(":");
     lcd.print(Minute);

if ((Tnow > LowSunriseT-CO2_Prestart*60) && (Tnow <= SunsetT-CO2_Prestop*60))
   {
   //digitalWrite(CO2RelayPin, LOW); 
  //digitalWrite(CO2RelayLED, HIGH); 
   //Serial.println("CO2 On"); 
   }
else if ((Tnow > SunsetT-CO2_Prestop*60) && (Tnow <= SunriseT-CO2_Prestart*60)){
  
   //digitalWrite(CO2RelayPin, HIGH); 
  //digitalWrite(CO2RelayLED, LOW); 
   //Serial.println("CO2 Off");
   
   } 
else if ((Tnow > SunriseT-CO2_Prestart*60) && (Tnow <= LowSunsetT-CO2_Prestop*60)){
  
   //digitalWrite(CO2RelayPin, LOW);  
   //digitalWrite(CO2RelayLED, HIGH);
   //Serial.println("CO2 On");
    
}  
 else if ((Tnow > LowSunsetT-CO2_Prestop*60)||(Tnow <= LowSunriseT-CO2_Prestart*60)) {
   
   //digitalWrite(CO2RelayPin, HIGH); 
  //digitalWrite(CO2RelayLED, LOW); 
   //Serial.println("CO2 Off");
    
 }
//define conditionals to initiate lighting changes 


if ((Tnow > LowSunriseT) && (Tnow < BrightenUpT))
   {
   CustomAccent(Red1,Green1,Blue1,White1,tstep1);
   
   }
   else if ((Tnow > BrightenUpT) && (Tnow < SunsetT))
   {
    Sunrise(tstep1);
       lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Sunrise");
   }
/*      else if ((Tnow > BrightenUpT) && (Tnow = TStorm))
   {
   ThunderStorm();
   }
   */
   else if ((Tnow > SunsetT) && (Tnow < SunriseT))
   {
   Sunset(tstep1);
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Low Sunset");
   }
   else if ((Tnow > SunriseT) && (Tnow < BrightenDownT))
   {
   Sunrise(tstep1);
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Full Spectrum");
   }
  /*    else if ((Tnow > SunriseT) && (Tnow >= WxNow) && (Tnow < WxEnd))
   {
 
     Storm2();
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Wx:");
   lcd.print(TSDurationH);
   lcd.print(":");
   lcd.print(TSDurationM);
   }*/
 else if ((Tnow > BrightenDownT) && (Tnow < LowSunsetT))
 {
    CustomAccent(Red1,Green1,Blue1,White1,tstep1);
       lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Low Sunset");
   }
 else if ((Tnow > LowSunsetT) && (Tnow < LowSunsetT+Evening_Moon*60)){
   MoonPhase(tstep1);
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Moon");
   }
   else if ((Tnow > LowSunsetT+Evening_Moon*60) || (Tnow < LowSunriseT)){
   Sunset(tstep1);
      lcd.setCursor(1,1); lcd.clearLine(1);
   lcd.print("Night Night");
   }
   }


#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:
      Orange();
      break;
    case 2:
      Blue();
      break;
    case 3:
      Rose();
      break;
    case 4:
      PowerOnOff();
      break;
    case 5:
      White();
      break;
    case 6:
      FullSpec();
      break;
    case 7:
      Purple();
      break;
    case 8:
      Play();
      break;
    case 9:
      RedUp();
      break;
    case 10:
      GreenUp();
      break;
    case 11:
      BlueUp();
      break;
    case 12:
      WhiteUp();
      break;
    case 13:
      RedDown();
      break;
    case 14:
      GreenDown();
      break;
    case 15:
      BlueDown();
      break;
    case 16:
      WhiteDown();
      break;
    case 17:
      M1Custom();
      break;
    case 18:
      M2Custom();
      break;
    case 19:
      M3Custom();
      break;
    case 20:
      M4Custom();
      break;
    case 21:
      Moon1();
      break;
    case 22:
      Moon2();
      break;
    case 23:
      Moon3();
      break;
    case 24:
      DawnDusk();
      break;
    case 25:
      Cloud1();
      break;
    case 26:
      Cloud2();
      break;
    case 27:
      Cloud3();
      break;
    case 28:
      Cloud4();
      break;
    case 29:
      Storm1();
      break;
    case 30:
      Storm2();
      break;
    case 31:
      Storm3();
      break;
    case 32:
      Storm4();
      break;
    case 33:
      RedNow=0;
      GreenNow=0; 
      BlueNow=0;
      WhiteNow=0;
      Sunrise(300);
      break;
    case 34:
       RedNow=42;
      GreenNow=42; 
      BlueNow=42;
      WhiteNow=42;
      Sunset(300);
      break;
    case 35:
    Sunset(300);
   CustomAccent(Red1,Green1,Blue1,White1,300);
   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
  
    
 // Serial.println(sMessage);  // Print message
 }}

void Orange()
{SendCode(codeOrange, 2, "Orange");
RedNow=42;
GreenNow=30; 
BlueNow=0;
WhiteNow=42;}

void Blue()
{SendCode(codeBlue, 2, "Blue");
 RedNow=0;
      GreenNow=0; 
      BlueNow=42;
      WhiteNow=42;}

void Rose()
{SendCode(codeRose, 2, "Rose");
  RedNow=42;
      GreenNow=0; 
      BlueNow=42;
      WhiteNow=42;}

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

void White()
{SendCode(codeWhite, 2, "White");
  RedNow=0;
      GreenNow=0; 
      BlueNow=0;
      WhiteNow=42;}

void FullSpec()
{SendCode(codeFullSpec, 2, "Full Spectrum");
   RedNow=42;
      GreenNow=42; 
      BlueNow=42;
      WhiteNow=42;}

void Purple()
{SendCode(codePurple, 2, "Purple");
RedNow=0;
      GreenNow=0; 
      BlueNow=42;
      WhiteNow=30;}

void Play()
{SendCode(codePlay, 1, "Play/Pause:");}

void RedUp()
{SendCode(codeRedUp, 2, "Red Up");
RedNow+=1;}

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

void BlueUp()
{SendCode(codeBlueUp, 1, "Blue Up");
BlueNow+=1;}

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

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

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

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

void WhiteDown()
{SendCode(codeWhiteDown, 2, "White Down");
WhiteNow=WhiteNow-1;}

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

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

void M3Custom()
{SendCode(codeM3Custom, 2, "Custom Mix 3");}

void M4Custom()
{SendCode(codeM4Custom, 2, "Custom Mix 4");}

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

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

void Moon3()
{SendCode(codeMoon3, 2, "Moonlight 3");}

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

void Cloud1()
{SendCode(codeCloud1, 2, "Cloud Cover 1");}

void Cloud2()
{SendCode(codeCloud2, 2, "Cloud Cover 2");}
  
void Cloud3()
{SendCode(codeCloud3, 2, "Cloud Cover 3");}

void Cloud4()
{SendCode(codeCloud4, 2, "Cloud Cover 4");}

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

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

void Storm3()
{SendCode(codeStorm3, 2, "Thunderstorm 3");}

void Storm4()
{SendCode(codeStorm4, 2, "Thunderstorm 4");}

void CustomAccent(int RedIn, int GreenIn, int BlueIn, int WhiteIn, int tstep )
{
  if(WhiteNow>WhiteIn){
  for (int i=1;i<43;i++){
  if(WhiteNow<WhiteIn){
  WhiteUp();
  delay(tstep);
  }
    if(WhiteNow>WhiteIn){
  WhiteDown();
  delay(tstep);
  }}}
for (int i=1;i<43;i++){
  if(RedNow<RedIn){
  RedUp();
  delay(tstep);
  }
    if(RedNow>RedIn){
  RedDown();
  delay(tstep);
  }
   if(GreenNow>GreenIn){
  GreenDown();
  delay(tstep);
  }
  if(GreenNow<GreenIn){
  GreenUp();
  delay(tstep);
  }
   if(BlueNow>BlueIn){
  BlueDown();
  delay(tstep);
  }
   if(BlueNow<BlueIn){
  BlueUp();
  delay(tstep);
  }}
  
  if(WhiteNow<WhiteIn){
  for (int i=1;i<43;i++){
  if(WhiteNow<WhiteIn){
  WhiteUp();
  delay(tstep);
  }
    if(WhiteNow>WhiteIn){
  WhiteDown();
  delay(tstep);
  }}}

} 

void Sunrise( int tstep )
{
  for (int i=1;i<43;i++){
  if(RedNow<42){
  RedUp();
  delay(tstep);
  }
    if(RedNow>42){
  RedDown();
  delay(tstep);
  }
   if(GreenNow>42){
  GreenDown();
  delay(tstep);
  }
  if(GreenNow<42){
  GreenUp();
  delay(tstep);
  }
   if(BlueNow>42){
  BlueDown();
  delay(tstep);
  }
   if(BlueNow<42){
  BlueUp();
  delay(tstep);
  }
 }
 for (int i=1;i<43;i++){
  if(WhiteNow<42){
  WhiteUp();
  delay(tstep);
  }
    if(WhiteNow>42){
  WhiteDown();
  delay(tstep);
  }
 }
FullSpec();
 RedNow=42;
  GreenNow=42;
  BlueNow=42;
  WhiteNow=42;
  delay(tstep);
} 

void Sunset( int tstep )
{
  for (int i=1;i<43;i++){
  if(WhiteNow<0){
  WhiteUp();
  delay(tstep);
  }
    if(WhiteNow>0){
  WhiteDown();
  delay(tstep);
  }
 }
  
for (int i=1;i<43;i++){
  if(RedNow<0){
  RedUp();
  delay(tstep);
  }
    if(RedNow>0){
  RedDown();
  delay(tstep);
  }
   if(GreenNow>0){
  GreenDown();
  delay(tstep);
  }
  if(GreenNow<0){
  GreenUp();
  delay(tstep);
  }
   if(BlueNow>0){
  BlueDown();
  delay(tstep);
  }
   if(BlueNow<0){
  BlueUp();
  delay(tstep);
  }
 }
 
M4Custom();
 RedNow=0;
  GreenNow=0;
  BlueNow=0;
  WhiteNow=0;
  delay(tstep);
} 
void MoonPhase(int tstep)
{
  
  int MoonBlue=(1+abs(31-(Day-1)*2))/2;
  int MoonRed=(1+abs(31-(Day-1)*2))/4;
  int MoonGreen=(1+abs(31-(Day-1)*2))/4;
  CustomAccent(MoonRed, MoonGreen, MoonBlue, 0, tstep);
}

  
  


int freeRam () {
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}

Quote:
Originally Posted by Curt_Planted View Post
Here is the latest code with moonlight and co2 control. Hope someone finds it useful. Had to zip the text doc as the limits on text docs are pretty skimpy on this forum. There is plenty of cleaning up to do in the code to minimize the file size but it's not even using half the memory of my arduino so if it aint broke....
drftndakota is online now   Reply With Quote Quick reply to this message
Old 07-23-2014, 08:12 PM   #517
Linwood
Planted Tank Enthusiast
 
PTrader: (0/0%)
Join Date: Jun 2014
Location: Cape Coral, Florida
Posts: 519
Default

Quote:
Originally Posted by drftndakota View Post
Somehow I ended up with a bad led went and picked up another and everything works perfect.
I did that as well. I think it was during debugging when I would turn it on steady as opposed to pulsing. They take a LOT more current pulsed than steady.
Linwood is offline   Reply With Quote Quick reply to this message
Old 08-18-2014, 09:46 AM   #518
75ona76
Planted Member
 
PTrader: (2/100%)
Join Date: May 2014
Location: Wichita, Ks
Posts: 218
Default

I thought I would share with you guys that I have two fixtures and a strip. The strip has a different device ID then the fixture lights. It has the smaller IR receiver. One of my fixtures has the small and one had the large round eye.
__________________
Using Tapatalk
75ona76 is offline   Reply With Quote Quick reply to this message
Old 08-19-2014, 05:12 AM   #519
maxwellag
Planted Tank Obsessed
 
maxwellag's Avatar
 
PTrader: (13/100%)
Join Date: Mar 2012
Location: Iowa
Posts: 475
Default

I keep getting compile error: "time_t does not name a type"
maxwellag is offline   Reply With Quote Quick reply to this message
Old 08-19-2014, 10:21 AM   #520
75ona76
Planted Member
 
PTrader: (2/100%)
Join Date: May 2014
Location: Wichita, Ks
Posts: 218
Default

Do you have the time library listed when you look for examples? I have those types if errors when it can't find the library files it needs.
__________________
Using Tapatalk
75ona76 is offline   Reply With Quote Quick reply to this message
Old 08-19-2014, 06:16 PM   #521
maxwellag
Planted Tank Obsessed
 
maxwellag's Avatar
 
PTrader: (13/100%)
Join Date: Mar 2012
Location: Iowa
Posts: 475
Default

Quote:
Originally Posted by 75ona76 View Post
Do you have the time library listed when you look for examples? I have those types if errors when it can't find the library files it needs.
Yeah I imported all of the libraries it needed, and it showed them in the list. Not sure why it happens. After I imported them, nothing happens. the Time.h and every other library except LiquidCrystal.h aren't orange.
maxwellag is offline   Reply With Quote Quick reply to this message
Old 08-19-2014, 07:05 PM   #522
mistergreen
No more Bow ties
 
mistergreen's Avatar
 
PTrader: (13/100%)
Join Date: Dec 2006
Location: Cincinnati
Posts: 14,238
Default

The libraries should be in documents:Arduino/libraries/
If you don't have a libraries folder, you can create one.

Oh, and restart the Arduino IDE.
mistergreen is online now   Reply With Quote Quick reply to this message
Old 08-21-2014, 04:32 AM   #523
maxwellag
Planted Tank Obsessed
 
maxwellag's Avatar
 
PTrader: (13/100%)
Join Date: Mar 2012
Location: Iowa
Posts: 475
Default

Quote:
Originally Posted by mistergreen View Post
The libraries should be in documents:Arduino/libraries/
If you don't have a libraries folder, you can create one.

Oh, and restart the Arduino IDE.
Thanks, I got it all sorted out. Code compiles fine now... Now my issue is wiring. I can't figure out a way to wire my 16x2 LCD, 6 pin RTC, IR receiver and IR LED all at once. Indychus, I understand if it's too much to ask, but could you please post a diagram of the final product wiring? I'm not sure which pins the LED and receiver are supposed to go in because they changed from your original post.
maxwellag is offline   Reply With Quote Quick reply to this message
Old 08-24-2014, 09:11 AM   #524
Curt_Planted
Algae Grower
 
PTrader: (0/0%)
Join Date: Feb 2014
Location: San Diego, CA
Posts: 35
Default

I was playing around tonight with my remote and adjusting my two lights for different color accents and found it looks amazing with different colors on the lights (one red one orange-yellow so it gives a graduated color scheme). I also found the adjustment much smoother by turning the lights on one at a time.

So the question is, how can the IR remote library be edited to accept an argument in the controller code to transmit from two different IR leds to allow independent control of two different lights? Obviously the arduino is capable of transmitting pwm on more than one pin but after working through the library I couldn't find a clear path to defining the led pin from function inputs. I got as far as the mark and space functions in the cpp file and then couldn't trace back clearly to the led definition in the .h file. I'm new to editing libraries in general so hopefully someone on here knows this library better than I. Any suggestions? I was thinking creating a second duplicate library that uses a different PIN could be a dirty way to do it, but not sure if the function name and variable conflicts could be easily avoided... perhaps by renaming the class for the function we are using?

Bump: Just had an idea for a hardware solution that would be pretty simple: just apply a voltage to transistor from a different pin to change which led is activated. Lol, or I could still dive into the code...
Curt_Planted is offline   Reply With Quote Quick reply to this message
Old 08-30-2014, 01:02 PM   #525
ipkiss
Planted Tank Obsessed
 
PTrader: (1/100%)
Join Date: Aug 2011
Location: FL
Posts: 354
Default

Hi Guys,

Has anyone tried to apply this to the Ecoxotic E-Series yet? Any compatibility between that and this Current Satellite+ ?
ipkiss is offline   Reply With Quote Quick reply to this message
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:

Log-in

Human Verification

In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.



Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 07:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright Planted Tank LLC 2012