Ramp up led strip

Hi,

I want to ramp up the brightness of a 10M led strip. I initially used pwm, but sometimes noticed a slight flicker. So I thought if I just used analogWrite going from 0 to 255 over 20 mins that would gradually increase the voltage. Instead of rapid on, offs that pwm uses. Am I correct in that?

This is my code:

int led = 3;

void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);

  for(int i=0;i<255; i++){
    analogWrite(led, i);
    delay(4700);
  }
  analogWrite(led, 0);
  delay(1000);
  analogWrite(led, 255);
}

void loop() {
  // put your main code here, to run repeatedly:
  
}

My next problem is I’m using a TIP120 that I just had lying around. I have the base connected to output pin 3 of arduino, Collector to the ground of the led striplight, and emmiter connected to the ground of the arduino, and ground of 12v power supply. 12v is going straight from power supply to led striplight.

I have no resistors or diodes in place. Do I need any?

Is there something better to use than a TIP120, because I have noticed it heats up alot, plus there is a 2v drop across it which means led’s dont get to full brightness.

Hope someone can advise the best way to do this.

Cheers,

Damien.

I initially used pwm,

How did you use PWM ?

I thought if I just used analogWrite going from 0 to 255 over 20 mins that would gradually increase the voltage. Instead of rapid on, offs that pwm uses. Am I correct in that?

analogWrite() uses PWM to turn the output on/off with a variable duty cycle so by using it you are applying PWM to the analogue output pin.

AnalogWrite IS PWM. AnalogWrite is a misnomer that confuses people all the time. To get true analog output you must low pass filter the PWM or use a digital to analog converter.

There are many LED strips and they can be controlled differently. Maybe it needs a resistor or constant current supply, maybe not. A link to the strip that you are using is necessary. The voltage drop is probably normal for a TIP120 passing a lot of current as is the heating. A logic level MOSFET with low Rds will not drop as much voltage and if properly sized should not get so hot. Again, the strip specifications need to be known to choose the right MOSFET.

This was the inital code I used that I thought was pwm. Cant remember what site I got it off.

int duty = 0;
int steps = 64;
int sunrisespeed = 5000;
int i;
int j;
int pulsepin = 3;

int lookup[64] = {1,2,4,6,9,12,16,20,25,30,36,
42,49,56,64,72,81,90,100,110,121,132,
144,156,169,182,196,210,225,240,256,272,289,
306,324,342,361,380,400,420,441,462,484,506,
529,552,576,600,625,650,676,702,729,756,784,
812,841,870,900,930,961,992,992,992};


// there are freq steps in the phasing
void setup()
{
  pinMode(pulsepin, OUTPUT);

  for (i=0; i<steps; i++)
  {
    duty = lookup[i] * 5;
    for (j=0; j<sunrisespeed; j++)
    {
      // one pulse of PWM
      digitalWrite(pulsepin, HIGH);
      delayMicroseconds(duty);
      digitalWrite(pulsepin, LOW);
      delayMicroseconds(5000-duty);
    }
  }
  digitalWrite(pulsepin, LOW);
  delay(1000);
  digitalWrite(pulsepin, HIGH);
}

void loop()
{
  
}

I thought using digitalWrite meant pwm.

I could see a flicker with this code. Using my simple analogWrite code give me a smooth increase with no flicker.

Will just reducing the voltage to the led strip light dim it properly or does it have to be pwm?

Would this MOSFET be ok to stop the voltage drop, plus carry 5 amps? N-Channel MOSFET 60V 30A - COM-10213 - SparkFun Electronics

Do I need any resistors between the MOSFET and arduino, or anywhere else?

Cheers.

Damien.

I have also just noticed that the max voltage to the led strip light is double the arduino voltage. Is this correct?

Is there any way of switching the full 12v to the led's with arduino?

Cheers,

Damien.

Is there any way of switching the full 12v to the led's with arduino?

A transistor or a MOSFET perhaps.