basic LED help

Well, adjusting the photoperiod with the computer is a piece of cake (Thank you Gorgok for changing ms to min, BTW I changed the long to unsigned int and it works)

For intensity, 0-254 is just as good as 0-100 as far as I'm concerned, as long as I can read the value. The ability to independently set intensity for each side of the scrubber is critical.
Is it easier to set things up where dimming is controlled by changing a number in the code rather than using buttons and a LCD?
 
Well, adjusting the photoperiod with the computer is a piece of cake (Thank you Gorgok for changing ms to min, BTW I changed the long to unsigned int and it works)

For intensity, 0-254 is just as good as 0-100 as far as I'm concerned, as long as I can read the value. The ability to independently set intensity for each side of the scrubber is critical.
Is it easier to set things up where dimming is controlled by changing a number in the code rather than using buttons and a LCD?

Most definitely!!!! wouldn't even need the lcd for this. all you would need is a few simple lines of code. (you would just upload a revised sketch to change the level) Though I could see benefit in having in place adjustment of levels and read out on the display.

Using pots with the code I posted and adding a line or two for photo period and a few more lines for the display wouldn't bee too tough a project.

Coding button menus is beyond anything I've messed with. gets to be an awful lot of code for a simple task many times, IMO.
 
*/

int read1, read2;

void setup()
{
//This is the PWM outputs. Make sure to connect the grounds!
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);

//Attach potentiometer middle pins to these pins.
pinMode(A1, INPUT);
pinMode(A2, INPUT);

}

void loop()
{
read1 = analogRead(A1);
read2 = analogRead(A2);


analogWrite(3, read1/4);
analogWrite(5, read2/4);

}[/CODE]


.
Is this sorta what the sketch would look like since I have only two channels?

"adding a line or two for photo period " Couldn't I just go in and change the minutes number at the delay line to adjust photoperiod?
 
Is this sorta what the sketch would look like since I have only two channels?

"adding a line or two for photo period " Couldn't I just go in and change the minutes number at the delay line to adjust photoperiod?

Yes, the down side to that though is that the sketch basically does nothing else until the end of the delay period. So you would not be able to make real time adjustments to the light level. (ie. once the sketch hits delay turning the pots won't change the light level until the sketch finishes and starts over some hours later)

There's a better (and of course more complicated) method on the arduino forum that can be used in place of "delay" to accomplish the same thing without stopping the rest of the sketch. (Alternatively the RTC could be used to keep time and not interrupt the rest of what your sketch is doing.) http://arduino.cc/en/Tutorial/BlinkWithoutDelay

Note, that if you are cool with just using the PC to make changes the "delay" code would work fine since it would reset each time you connected to the computer to make a change to the code. (you would wan't to power down the lights when you do this)

Downside of not using an RTC is that in event of a power out it just starts and runs from the beginning, so if you are running opposite your tank light cycle then you occasionally may need to reset things. (don't recall your plan there)

As a back up plan you can always go old school and use light timers to run your photo-period and just use the arduino to set and display light intensity.
 
Personally I would use the arduino to control the timing and dimming. If you want simple code for the user interaction, a pot can be used to set the level (just needs one line to read the voltage from the pot and one or two lines to convert that into a PWM level between 0 & 254), and using the RTC to simply switch on and off is fairly easy.

I would offer to put you a sketch together to do this, but might take me a week before I have chance. You'd still need to change to code to alter the times, but brightness would just be adjusting the pot. And you could easily use two pots, one for each bank of lights...

Tim
 
It would be OK if any changes made to photoperiod timing or intensity didn't take effect until the sketch cycled. The photoperiod will probably be only be about 4-5 hours.

This scrubber won't be running opposite the tank's lights-it will be running all the time-the red side will run 4-5 hours, then the blue side will run 4-5 hours, then back to the red side.

I've been trying to get my dimming act together. I found a dimming program at the arduino site that called for the Process program, so I downloaded it. I am having nothing but trouble with Process. To the point of pulling what's left of my hair out. :(

Tim, if you could put a sketch together, I'd be forever grateful. If you were able to find the time, would it be an addition to the sketch in post 76?

I was hoping to have the RTC by now, but it could be another week or three. Ditto that slow boat for the relays. Even if all the parts were sitting around, I'd be in no kind of hurry. Speaking of parts, what kind of pots would work? I have a few laying around, but don't know if they are the right value.

Thank you zachts. Thank you perkint.
 
Reverse Audio Anti Log Taper Potentiometers
-gives you finer control on the low level dimming

Audio Potentiometers
-give finer control on the high level dimming

linear (standard) Taper Potentiometers
-give even resolution accross the dimming range

5k ohm or 10k ohm should work, just changes the resolution of the dimming.
 
PHP:
#include <EEPROM.h>
#include <LiquidCrystal.h>
#include <Button.h>
int redLED = 8;        
int redFAN = 9; 
int blueLED = 10;
int blueFAN = 11;
long minutesInMs(int m){
return m*60000;  //converts milliseconds to minutes
}


void setup()                      // run once, when the sketch starts
{
  pinMode(redLED, OUTPUT);        // sets the digital pins as outputs
  pinMode(redFAN, OUTPUT);      
  pinMode(blueLED, OUTPUT);
  pinMode(blueFAN, OUTPUT);
}


void loop() {
  digitalWrite(redLED, HIGH);   
  digitalWrite(redFAN, HIGH);    
  digitalWrite(blueLED, LOW);
  digitalWrite(blueFAN, LOW);
  delay(minutesInMs(1)); 
  digitalWrite(redLED, LOW);    
  digitalWrite(redFAN, LOW);    
  digitalWrite(blueLED, HIGH);
  digitalWrite(blueFAN, HIGH);
  
  delay(minutesInMs(1));    
}

// Returns minutes in milliseconds

So that's the code you have currently. What are you doing with it and what do you want adding? You only have on and off on the LEDs currently. What drivers are you using? And you want a fixed time on and off every few hours for the LEDs? Varying the level by PWM based on the setting of 2 'pots (1 for the blues, 1 for the reds)?

Tim
 
I plan to put something like 300 in both delays for a 5 hr. photoperiod. The red would be on for 5 hours as well as the fan for the red side, then the red turns off and the blue side kicks on for 5 hours. So I think the alternating part is done. I hope so anyway. It seemed to work on the breadboard.
delay(minutesInMs(300));

I need to dim each side independently. If somewhere there was a number associated with the dimming level, that would be outstanding.

Here's the relay that's on the way for the 5V fans. http://www.ebay.com/itm/371030375305?_trksid=p2059210.m2749.l2649&ssPageName=STRK:MEBIDX:IT

The power supply http://www.ebay.com/itm/331286872874?_trksid=p2059210.m2749.l2649&ssPageName=STRK:MEBIDX:IT

I also have 8 Meanwell LDD-700LS modules-one for each string of 10 3W LEDs.

A RTC 1307 is also on the way.

I have this 25K fine adjustment pot http://www.ebay.com/itm/5-x-25K-OHM...174?pt=LH_DefaultDomain_0&hash=item3cc93fcfee

and this not so fine adjustment 10K pot http://www.ebay.com/itm/10-x-10K-OH...476?pt=LH_DefaultDomain_0&hash=item3a69b91174

Thanks a ton!
 
PHP:
int redLED = 8;        
int redFAN = 9; 
int redPOT = ; //set potentiometer pins
int blueLED = 10;
int blueFAN = 11;
int bluePOT = ; //see above

long minutesInMs(int m){
  return m*60000;  //converts milliseconds to minutes
}

unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
boolean redOn = false;

void setup()                      // run once, when the sketch starts
{
  pinMode(redLED, OUTPUT);        // sets the digital pins as outputs
  pinMode(redFAN, OUTPUT);      
  pinMode(blueLED, OUTPUT);
  pinMode(blueFAN, OUTPUT);
}

void loop() {
  currentMillis = millis();
  if (currentMillis - previousMillis < 0){
    previousMillis = 0; //for when millis() rolls back to 0
  }
  if (redOn) {
    analogWrite(redLED, (analogRead(redPOT)/ 4)); 
    digitalWrite(redFAN, HIGH);    
    digitalWrite(blueLED, LOW);
    digitalWrite(blueFAN, LOW);
  }
  else {
    analogWrite(blueLED, (analogRead(bluePOT)/ 4)); 
    digitalWrite(blueFAN, HIGH);    
    digitalWrite(redLED, LOW);
    digitalWrite(redFAN, LOW);
  }
  if (currentMillis - previousMillis > minutesInMS(300)) {
    previousMillis = currentMillis;
    redOn = !redOn; //switches from red to blue and back
  }
  delay(50); //just a delay to slow it down some
}

This will alternate the sides, while keeping real(ish) time dimming for that side active. Still need to reprogram the thing to change the duration, and there is no break between one side on and the other... I have no means of testing, but don't really foresee any issues. Some ugly copy/paste code that could be done away with with a neater function and parameters, but this is clear enough.
 
I think you need to include setting the pot pins to "input" in the void setup section? or is input the default, I forget........otherwise there you have it....

pinMode(redPOT, INPUT);
pinMode(bluePOT, INPUT);
 
Its entirely possible, but i never saw a pin declared as input in my searches of the arduino site. Probably wouldn't hurt anything to declare them even if they were input by default.
 
I thought the heating scheme was squared away, but ran into snags. It’s straightened out so my spare time is back on the algae filter. Hope you guys are still around and willing to help…
Gorgok, when I try to upload that sketch, the third line gets highlighted and ‘expected primary-expression before token’ error is listed at the bottom of the sketch window.
I’m guessing here-is the pot’s wiper assigned to a pin and the other two sides of the pot connected between the LDD 700 and LEDs?
 
Made a few adjustements to the code. it was missing the pins assigned for the pot inputs (I just picked 6&7 you can change them if you wish)

Code:
int redLED = 8;        
int redFAN = 9; 
int redPOT = 6; //set potentiometer pins
int blueLED = 10;
int blueFAN = 11;
int bluePOT = 7; //see above

int m = 300; //enter delay time in minutes for switching between red and blue LEDs

long minutesInMs(int m){
  return m*60000;  //converts milliseconds to minutes
}

unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
boolean redOn = false;

void setup()                      // run once, when the sketch starts
{
  pinMode(redLED, OUTPUT);        // sets the digital pins as outputs
  pinMode(redFAN, OUTPUT);      
  pinMode(blueLED, OUTPUT);
  pinMode(blueFAN, OUTPUT);
}

void loop() {
  currentMillis = millis();
  if (currentMillis - previousMillis < 0){
    previousMillis = 0; //for when millis() rolls back to 0
  }
  if (redOn) {
    analogWrite(redLED, (analogRead(redPOT)/ 4)); 
    digitalWrite(redFAN, HIGH);    
    digitalWrite(blueLED, LOW);
    digitalWrite(blueFAN, LOW);
  }
  else {
    analogWrite(blueLED, (analogRead(bluePOT)/ 4)); 
    digitalWrite(blueFAN, HIGH);    
    digitalWrite(redLED, LOW);
    digitalWrite(redFAN, LOW);
  }
  if (currentMillis - previousMillis > m) {
    previousMillis = currentMillis;
    redOn = !redOn; //switches from red to blue and back
  }
  delay(50); //just a delay to slow it down some
}
 
I’m guessing here-is the pot’s wiper assigned to a pin and the other two sides of the pot connected between the LDD 700 and LEDs?

No, the pot gets connected as follows with the legs numbered 1,2,3 from left to right or right to left (doesn't matter)

leg 1 to 5volt or VCC pin from the arduino board

leg 2 to input pin (6 or 7)

leg 3 to GND pin on the Arduino board.

the pots may all share the same VCC and GND pins.

I'm not sure that it is necessary but It would be wise to install a current limiting resistor between VCC and leg 1 of the pots.
 
Last edited:
Thanks everyone of you guys!
I went ahead and declared the redPOT and bluePOT as inputs and uploaded the sketch.

I think it's ready to solder together. Would something in the 1K range be a good current limiting resistor between VCC and leg 1 of the pots?

I have both 5K and 10K pots-which would you choose?
 
1kohm should be fine. (though looking back at the analogue read examples from the arduino site it doesn't look like it needs to be used, and come to think of it would make the voltage lower than 5v so you wouldn't ever get a full 255 pwm signal to the LED drivers.)

Maybe someone else will chime in for a second opinion?

10k pot will give finer resolution.
 
Thanks. Also, would it be good practice to set up a central ground from the power supply and run lines to ground the Arduino, relays and -V out on the LDD-700 modules?
 
Back
Top