The Planted Tank Forum - Reply to Topic
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 > Improved Arduino LED lighting code

Thread: Improved Arduino LED lighting code Reply to Thread
Title:
  
Message:
Post Icons
You may choose an icon for your message from the following list:
 

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:
If you do not want to register, fill this field only and the name will be used as user name for your post.
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.



Additional Options
Miscellaneous Options

Topic Review (Newest First)
04-17-2014 08:50 PM
O2surplus
Quote:
Originally Posted by jeffkrol View Post
Yep that is the next project.. My orig order was a plug and play one (just direct plug to the Typhon serial out) from your recommendation I believe, but they sent a "solder it yourself" board.. grrr ..
As soon as the parts come from LED Groupbuy come.. I get to "play" a bit..
(so who did they steal their 5up Meanwell boards from.. )
As you may remember I upgraded my shooting iron..

now which one is ground.............................. (just kidding)
LOL- I wouldn't call it stealing ... the designs were posted online and they just jumped on the band wagon like everyone else. Stealing is when you're a Chinese seller that's selling my designs as your own, but at the same time, too lazy to remove my name from the silkscreen. It's too bad for them now as most of my designs have become nearly impossible to mas produce using only machines. They'd need to employ an army of slaves... er.... "workers" to perform all the hand soldering- LOL. Oh Yeah? What was I thinking? they already do.
04-17-2014 08:12 PM
jeffkrol
Quote:
Originally Posted by O2surplus View Post
LOL- Using a USB port alone does not qualify you as a "Geek". But if you whip out a FTDI adapter too......Now you're qualified.
Yep that is the next project.. My orig order was a plug and play one (just direct plug to the Typhon serial out) from your recommendation I believe, but they sent a "solder it yourself" board.. grrr ..
As soon as the parts come from LED Groupbuy come.. I get to "play" a bit..
(so who did they steal their 5up Meanwell boards from.. )

As you may remember I upgraded my shooting iron..

now which one is ground.............................. (just kidding)
04-17-2014 07:04 PM
O2surplus
Quote:
Originally Posted by jeffkrol View Post
I take it this is till only 2 channels dimming???
Yep.

Also do you have any idea what RTC Steves Typhon uses..?
Steve's is stealing er..... selling the original version of the Typhon, so it should be the DS1307.

I'll be hooking up the serial USB port soon so I will finally be able to play "geek"...
LOL- Using a USB port alone does not qualify you as a "Geek". But if you whip out a FTDI adapter too......Now you're qualified.
04-17-2014 05:58 PM
jeffkrol
Quote:
Originally Posted by O2surplus View Post

SNIP..
I take it this is till only 2 channels dimming???
Also do you have any idea what RTC Steves Typhon uses..?

I'll be hooking up the serial USB port soon so I will finally be able to play "geek"...
04-17-2014 03:33 PM
Guy.hall This is spot on and I will be using this on mine as soon as there is water in it... On the workbench I couldnt even tell it was dimming it is that smooth. I have just got the 20x4 lcd to match it so hopefully can put ph etc on it too in the future.

Thanks O2.
04-09-2014 02:01 PM
O2surplus Hey everyone-

I'm no coding genius like "Sink" but I did manage to make his code compatible with Arduino 1.05 and add some new features. I've been using this version of the code to control the lighting on my tank fo a little over a week and it works great.

Note: If you already have the original Arduino 23 version of this code and want to upgrade to this one you'll need to update your libraries first and compile the code using Arduino 1.0. Updating the libraries is easy. Open each Library header file (.h) and add the following line of code to the beginning of the "define section".

Code:
#if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h"#endif
Here's what I added-

1.) I2C LCD supported. Time/Date/Temp/Dimming mode & fan control status are all displayed on the LCD.
2.) Dallas Temp support- Dallas OneWire DS18B20 Temp sensors are auto detected and the temperature is displayed to the LCD.
3.)Cooling fan control logic added in- Digital Pin#8 Turns on/off in accordance with the Led state.

Here's a photo of the Lcd -


Here's the modified code-
Code:
/*
 * Name:    tank-control.pde
 * Author:    User "sink" at plantedtank.net forums
 * URL:        http://bitbucket.org/akl/tank-control
 *
 * This is control code for an aquarium lighting system.  It is intended to be
 * run on an Arduino microcontroller board.  It allows independant
 * high-resolution control of two PWM outputs (normally connected to LED
 * drivers) and complete flexibility with respect to intensity, timing
 * schedules, and sunrise/sunset.
 *
 * This code requires the following libraries: Wire, TimerOne, 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.  
 */
/* NOTICE: 4/2/2014- Addtional support for I2C LCD & Dallas OneWire Temperature readout added by O2Surplus.
              The original Libraries used in this version of the code were updated for use with Arduino 1.5-r2.
              Please make sure to use the proper version of said libraries. */
              
#include <TimerOne.h>
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>
#include <OneWire.h> // added to original code by O2Surplus 4/2/2014
#include <LiquidCrystal_I2C.h>// added to original code by O2Surplus 4/2/2014

//LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

//Temperature chip i/o
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2

OneWire ds(DS18S20_Pin);  // on digital pin 2

int fanEnable = 8;// assigns cooling fan ON/OFF control to digital pin 8.

/*
 * IMPORTANT:  These *must* be the pins corresponding to the Timer1 timer on
 * the ATmega168/328.  These are digital pins 9 and 10 on the Uno/Duemilanove.
 */
const int kChan0Pin = 9; // Channel 0 Pin
const int kChan1Pin = 10; // Channel 1 Pin

// All times are in seconds since midnight (valid 0 - 86399)
const long kTurnOn = 32400; // time dawn begins - 0900hrs
const long kTurnOff = 75600; // time sunset begins - 2100hrs

/*
 * Light "state" represents the PWM duty cycle for each channel This normally
 * dictates light intensity. It is an array { duty_chan_1, duty_chan_2 }.
 * Possible values for duty cycle are 0 - 1023.
 */
const int kDayState[] = { 1023,1023 }; // daytime LED state
const int kNightState[] = { 0, 0 }; // nighttime LED state

// duration (in seconds) of sunrise/sunset fade
const long kFadeDuration = 3600; // 60 minutes

long ctr;

/*
 * fader -- Determine output state for a given time to provide smooth fade from
 * one state to another.
 *     Args:
 *     start_time  -- time (in seconds) of start of fade
 *     start_state -- beginning state
 *     end_state   -- ending state
 *     out         -- array to update with state
 */
void fader(long start_time, const int start_state[], const int end_state[], int out[2]) {

  float per_second_delta_0 = (float) (end_state[0]-start_state[0])/kFadeDuration;
  float per_second_delta_1 = (float) (end_state[1]-start_state[1])/kFadeDuration;

  long elapsed = ctr-start_time;

  out[0] = start_state[0] + per_second_delta_0 * elapsed;
  out[1] = start_state[1] + per_second_delta_1 * elapsed;
}

// return seconds elapsed since midnight
long seconds_since_midnight() {
  time_t t = now();
  long hr = hour(t);
  long min = minute(t);
  long sec = second(t);
  long total = hr * 3600 + min * 60 + sec;
  return total;
}

// set output state
void set_state(const int state[]) {
  if (state[0] >= 0 && state[0] <= 1023) Timer1.setPwmDuty(kChan0Pin, state[0]);
  if (state[1] >= 0 && state[1] <= 1023) Timer1.setPwmDuty(kChan1Pin, state[1]);
}

/*
 * determine_state -- This is where the actual timing logic resides.  We
 * examine ctr (seconds since midnight) and then set output state accordingly.
 * Variable ctr rolls back to 0 at midnight so stages that cross midnight (ie:
 * nighttime) are broken up into two stages.
 */
void determine_state() {
  if ( ctr >= 0 && ctr < kTurnOn ) { // night
      set_state(kNightState);
      
      lcd.setCursor(0,2);
      //lcd.print("                   ");
      lcd.setCursor(5,2);
      lcd.print("NIGHT/MODE");         // LCD coding added by O2Surplus 4/2/2014
      digitalWrite(fanEnable,LOW);
      lcd.setCursor(6,3);
      lcd.print("FANS-OFF");
      
  } else if ( ctr >= kTurnOn && ctr <= (kTurnOn+kFadeDuration) ) { // sunrise
    int foo[2];
    fader(kTurnOn, kNightState, kDayState, foo);
    set_state(foo);
      
      lcd.setCursor(0,2);
      //lcd.print("                   ");
      lcd.setCursor(3,2);
      lcd.print("SUNRISE/MODE");              // LCD coding added by O2Surplus 4/2/2014
      digitalWrite(fanEnable, HIGH);
      lcd.setCursor(7,3);
      lcd.print("FAN-ON");
  } else if ( ctr > (kTurnOn+kFadeDuration) && ctr < kTurnOff ) { // day
    set_state(kDayState);
      
      lcd.setCursor(0,2);
      //lcd.print("                   ");
      lcd.setCursor(5,2);             
      lcd.print("DAY/MODE");              // LCD coding added by O2Surplus 4/2/2014
      digitalWrite(fanEnable, HIGH);
      lcd.setCursor(7,3);
      lcd.print("FAN-ON");
  } else if ( ctr >= kTurnOff && ctr <= (kTurnOff+kFadeDuration) ) { // sunset
    int foo[2];
    fader(kTurnOff, kDayState, kNightState, foo);
    set_state(foo);
      lcd.setCursor(0,2);
      //lcd.print("                   ");
      lcd.setCursor(5,2);
      lcd.print("SUNSET/MODE");              // LCD coding added by O2Surplus 4/2/2014
      //lcd.setCursor(11,2);
      //lcd.print("  ");
      digitalWrite(fanEnable, HIGH);
      lcd.setCursor(7,3);
      lcd.print("FAN-ON");
  } else if ( ctr > (kTurnOff+kFadeDuration) && ctr < 86400 ) { // night
    set_state(kNightState);
      lcd.setCursor(0,2);
      //lcd.print("                   ");
      lcd.setCursor(5,2);
      lcd.print("NIGHT/MODE");          // LCD coding added by O2Surplus 4/2/2014
      digitalWrite(fanEnable,LOW);
      lcd.setCursor(6,3);
      lcd.print("FANS-OFF");
  }
}

/*
 * 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);
 
}
void displayDigits(int digits) {
  lcd.print(":");
  if(digits < 10)
    lcd.print('0');
  lcd.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 lcdClockDisplay() {
  lcd.setCursor(0,0);
  lcd.print(hour());
  displayDigits(minute());
  displayDigits(second());
  lcd.print("  ");
  lcd.print(month());
  lcd.print("/");
  lcd.print(day());
  lcd.print("/");
  lcd.print(year()); 
   
}
void setup() {
  Serial.begin(115200); // Max for Arduino Uno
  setSyncProvider(RTC.get);
  setSyncInterval(120);
  Wire.begin();
  lcd.begin(20,4);         // initialize the lcd for 20 chars 4 lines and turn on backlight
  Timer1.initialize(6666); // 150Hz PWM
  pinMode(kChan0Pin, OUTPUT);     
  Timer1.pwm(kChan0Pin, 0);
  pinMode(kChan1Pin, OUTPUT);     
  Timer1.pwm(kChan1Pin, 0);
  pinMode(fanEnable,OUTPUT);   // Fan control coding added by O2Surplus 4/2/2014
}

void loop () {
  float temperature = getTemp();// Temperature serial display coding addded by O2Suplus 4/2/2014
  Serial.println(temperature);
  ctr = seconds_since_midnight();// Original code
 
  lcd.setCursor(0,1);          // Temperature to I2C LCD added by O2Surplus 4/2/2014
  lcd.print("Temp C = ");
  lcd.print(temperature);
 
  determine_state();// Original code
  Serial.print("ctr: ");
  Serial.print(ctr); // display counter
  Serial.println();
  digitalClockDisplay(); //display time
  Serial.println();
  lcd.setCursor(0,0); //Time/Date to I2C display added 4/2/2014 by O2Surplus
  lcd.println();
  lcdClockDisplay();
 
   

  
  delay(1000); // no need to do anything until next second
}// Original Code ends here.


float getTemp(){
  //returns the temperature from one DS18S20 in DEG Celsius // Added by O2Suplus 4/2/2014

  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1000;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return -1000;
  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      Serial.print("Device is not recognized");
      return -1000;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);    
  ds.write(0xBE); // Read Scratchpad

  
  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }
  
  ds.reset_search();
  
  byte MSB = data[1];
  byte LSB = data[0];

  float tempRead = ((MSB << 8) | LSB); //using two's compliment
  float TemperatureSum = tempRead / 16;
  
  return TemperatureSum;
  
}
12-07-2013 09:59 AM
TomLS Okay, I have tried to make a long post on here twice now, regarding questions about the code, but apparently it still remains in moderation. How long does this usually take?!

In the meantime I have made some achievements based on this code, which I would like to give back to the community.
1) modified the libraries to make it fully compatible with IDE 1.0,
2) added temperature probe support,
3) added i2c LCD support,
4) split out the code to allow for different start times and durations for the fade of each channel.

I will attempt to post this up here in the next couple of days!
12-03-2013 06:17 PM
TomLS Oh, and its probably worth noting that I'm using the Nano V3 ATMega328 board, but from what I can tell it's functionally identical to the uno...

This is related to a post which is still apparently being moderated!...
12-01-2013 09:23 PM
Pady Hello all of you
First of all I would like to say big thanks to Sink and O2surplus and all you other guys :-)
You all helped me getting started with my LED controller Arduino.
I'll have to read it all again to understand how it really works...
I need to fix up 4 channels with different 100% brightness and sunrise/down and moon light. Also putting in and reading everything to my laptop.
12-01-2013 05:05 PM
shrimper23
I2C freezing

Hey Sink, wanted to see if you might be able to advise me on my project here. I have your code working beautifully with the Adafruit 16-channel 12-bit pwm driver. However, after integrating it into my full control code i'm having an issue. The code will perform as expected right up to the dimming stage, when it hits my LCD goes blank, LED's flash, and the whole I2C bus stops dead. It seems to me I may have to much going on with the I2C. I'm using an UNO R3 with a DS1307, the Adafruit PWM controller, and their I2C 16x2 LCD on the bus. Please let me know if you have any idea how I might fix this issue. Thank you.


#include <Wire.h>
#include "RTClib.h"
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <Adafruit_PWMServoDriver.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>

#define OFF 0x0
#define WHITE 0x7
#define rxpin 3
#define txpin 2

RTC_DS1307 RTC;
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

const long kTurnOn = 39000; // 37800time dawn begins - 0900hrs
const long kTurnOff = 59000; // 70200 time sunset begins - 2100hrs
const int kDayState[] = { 3000, 4000, 4000, 4000, 0, 0, 2000, 3000 }; // daytime LED state
const int kNightState[] = { 0, 4, 45, 4, 2000, 0, 0, 4 }; // nighttime LED stat
const long kFadeDuration = 0;
long ctr;
int state_chan1, state_chan2, state_chan3, state_chan4, state_chan5, state_chan6, state_chan7, state_chan8;

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
SoftwareSerial myserial(rxpin, txpin);
int DS18S20_Pin = 4;
OneWire ds(DS18S20_Pin);

int floatstate = 0;

long phReadInterval = 10000;
long previousMillisPH = 0;
int PHState = HIGH;
float PH_Val;

void fader(long start_time, const int start_state[], const int end_state[], int out[2]) {

float per_second_delta_0 = (float) (end_state[0]-start_state[0])/kFadeDuration;
float per_second_delta_1 = (float) (end_state[1]-start_state[1])/kFadeDuration;
float per_second_delta_2 = (float) (end_state[2]-start_state[2])/kFadeDuration;
float per_second_delta_3 = (float) (end_state[3]-start_state[3])/kFadeDuration;
float per_second_delta_4 = (float) (end_state[4]-start_state[4])/kFadeDuration;
float per_second_delta_5 = (float) (end_state[5]-start_state[5])/kFadeDuration;
float per_second_delta_6 = (float) (end_state[6]-start_state[6])/kFadeDuration;
float per_second_delta_7 = (float) (end_state[7]-start_state[7])/kFadeDuration;

long elapsed = ctr-start_time;

out[0] = start_state[0] + per_second_delta_0 * elapsed;
out[1] = start_state[1] + per_second_delta_1 * elapsed;
out[2] = start_state[2] + per_second_delta_2 * elapsed;
out[3] = start_state[3] + per_second_delta_3 * elapsed;
out[4] = start_state[4] + per_second_delta_4 * elapsed;
out[5] = start_state[5] + per_second_delta_5 * elapsed;
out[6] = start_state[6] + per_second_delta_6 * elapsed;
out[7] = start_state[7] + per_second_delta_7 * elapsed;
}

long seconds_since_midnight() {
DateTime now = RTC.now();
long hr = now.hour();
long min = now.minute();
long sec = now.second();
long total = hr * 3600 + min * 60 + sec;
return total;
}

void set_state(const int state[]) {
if (state[0] >= 0 && state[0] <= 4096) {
pwm.setPWM(0, 0, state[0]);
state_chan1 = state[0]; }
if (state[1] >= 0 && state[1] <= 4096) {
pwm.setPWM(1, 0, state[1]);
state_chan2 = state[1]; }
if (state[2] >= 0 && state[2] <= 4096) {
pwm.setPWM(2, 0, state[2]);
state_chan3 = state[2]; }
if (state[3] >= 0 && state[3] <= 4096) {
pwm.setPWM(3, 0, state[3]);
state_chan4 = state[3]; }
if (state[4] >= 0 && state[4] <= 4096) {
pwm.setPWM(4, 0, state[4]);
state_chan5 = state[4]; }
if (state[5] >= 0 && state[5] <= 4096) {
pwm.setPWM(5, 0, state[5]);
state_chan6 = state[5]; }
if (state[6] >= 0 && state[6] <= 4096) {
pwm.setPWM(6, 0, state[6]);
state_chan7 = state[6]; }
if (state[7] >= 0 && state[7] <= 4096) {
pwm.setPWM(7, 0, state[7]);
state_chan8 = state[7]; }
}

void determine_state() {
if ( ctr >= 0 && ctr < kTurnOn ) { // night
set_state(kNightState);
} else if ( ctr >= kTurnOn && ctr <= (kTurnOn+kFadeDuration) ) { // sunrise
int foo[2];
fader(kTurnOn, kNightState, kDayState, foo);
set_state(foo);
} else if ( ctr > (kTurnOn+kFadeDuration) && ctr < kTurnOff ) { // day
set_state(kDayState);
} else if ( ctr >= kTurnOff && ctr <= (kTurnOff+kFadeDuration) ) { // sunset
int foo[2];
fader(kTurnOff, kDayState, kNightState, foo);
set_state(foo);
} else if ( ctr > (kTurnOff+kFadeDuration) && ctr < 86400 ) { // night
set_state(kNightState);
}
}

float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad


for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}

ds.reset_search();

byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;

return TemperatureSum;

}

void getPHvalue(){
unsigned long currentMillisPH = millis();

if(currentMillisPH - previousMillisPH > phReadInterval){
previousMillisPH = currentMillisPH;
if(PHState == HIGH){
PHState = LOW;
}
else {
PHState = HIGH;
myserial.print("r\r");
while(myserial.available() > 0){
PH_Val = myserial.parseFloat();
if(myserial.read() == '\r');
}
}
}
}

void setup() {
myserial.begin(38400);
RTC.begin();
lcd.begin(16,2);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, INPUT);
pwm.begin();
pwm.setPWMFreq(800);
ctr = seconds_since_midnight();
Serial.print(ctr);
}

void loop(){
ctr = seconds_since_midnight();
determine_state();
floatstate = digitalRead(7);
if (floatstate == HIGH) {
digitalWrite(6, HIGH);
delay(10000);
digitalWrite(6, LOW);
}
else {
digitalWrite(6, LOW);
}

if ( ctr >= 0 && ctr < 26000 ) {
lcd.setBacklight(OFF);
} if ( ctr >= 0 && ctr < kTurnOn ) {
digitalWrite(5, LOW);
} else if ( ctr > (kTurnOff+kFadeDuration) && ctr < 86400 ){
lcd.setBacklight(OFF);
digitalWrite(5, LOW);
}
else {
lcd.setBacklight(WHITE);
digitalWrite(5, HIGH);
}


DateTime now = RTC.now();
lcd.setCursor(0, 1);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);

getPHvalue();
lcd.setCursor(0,0);
lcd.print("PH:");
lcd.print(PH_Val);

float temperature = getTemp();
lcd.setCursor(8,0);
lcd.print(temperature);
lcd.print("C");

delay(5000); //just here to slow down the output so it is easier to read

}

My apologies for the post length.
12-01-2013 03:07 PM
Gisimo Hello everyone i am considering to make a new light for at nano tank and i was wondering if i could use a Arduino Micro or mini instead of an uno ??
10-08-2013 05:46 PM
estill To address the 0-10V "signal", could you use the Arduino PWM output to control a transistor or MOSFET? I know you can do this to drive a DC motor, and it will fool most multimeters into seeing a lower voltage.
10-07-2013 03:50 PM
HunterX
Quote:
Originally Posted by O2surplus View Post
The Apex controller outputs a 0-10V analog signal to dim the leds. So chances are good that the dimmable drivers in the BuildMyLed fixture are designed to accept that type of dimming control signal. The Arduino outputs a 5V PWM signal, so it won't be directly compatible with the drivers in the BML fixture.
If you have your heart set on using the arduino as your controller, just purchase LED drivers that accept a 5V PWM signal directly, and you'll be set.Checkout the Meanwell LDD-L & LDD-H series of drivers. They will work well for your application, and they're cheap too. Here's a link-LDD-1000H | Mean-Well LDD-1000H | USA Warehouse
Thanks for your reply. I'm sending you a PM.
10-06-2013 10:28 PM
O2surplus
Quote:
Originally Posted by HunterX View Post
Hello everyone. I want to thank you all for taking the time to put this information on the forum. I do have a question. Has anyone used the arduino to control LED fixtures made by build my led.com? From what I understand, they are built with LED Drivers built into the fixture. Further more, they can ship with a prefab APEX dimming cable. It appears to be a standard RJ45 connection on the end that would plug into the controller. Would it be possible do use the Arduino with that setup to control the LEDs? if so what would I need?

Thank you in advance for your response.

The Apex controller outputs a 0-10V analog signal to dim the leds. So chances are good that the dimmable drivers in the BuildMyLed fixture are designed to accept that type of dimming control signal. The Arduino outputs a 5V PWM signal, so it won't be directly compatible with the drivers in the BML fixture.
If you have your heart set on using the arduino as your controller, just purchase LED drivers that accept a 5V PWM signal directly, and you'll be set.Checkout the Meanwell LDD-L & LDD-H series of drivers. They will work well for your application, and they're cheap too. Here's a link-LDD-1000H | Mean-Well LDD-1000H | USA Warehouse
10-06-2013 05:15 AM
HunterX Hello everyone. I want to thank you all for taking the time to put this information on the forum. I do have a question. Has anyone used the arduino to control LED fixtures made by build my led.com? From what I understand, they are built with LED Drivers built into the fixture. Further more, they can ship with a prefab APEX dimming cable. It appears to be a standard RJ45 connection on the end that would plug into the controller. Would it be possible do use the Arduino with that setup to control the LEDs? if so what would I need?

Thank you in advance for your response.
This thread has more than 15 replies. Click here to review the whole thread.

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


All times are GMT. The time now is 04:03 AM.


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