Controlling led array with Arduino with LM3406

Hi,

I have a circuit with LM3406HV driving it.

The 3406 has a dedicated DIM pin to control the leds with PWM. I just don't get the PWM thing i think..

I used a basic on off code:

void loop() { digitalWrite(ledPin, HIGH); delay(2000); digitalWrite(ledPin, LOW); delay(1500); }

I connected let's say PWM pin 9 to the DIM in the controller and even tested I can see arduino goes from 0V to 5V....however nothing happends to the array...constant on.

How do I connect the arduino to the circuit? only the pin9 or also GND? How do I use fade...not just on off (I mean code-wise...) could find any simple codes to dim with PWM...(Something like duty cycles so I can choose 40% 50% 100% etc.)

THanks guys! ;)

The DIM pin expects a PWM signal. The Percentage of ON time to OFF time during pulse width will control brightness.

The way you are starting to do it now would require you to continue to write your own PWM routines... but some already exist... if you prefer to try them.

(I did not write this below, I just copied it here so you could look at it.)

analogWrite():

The pins marked PWM (pins 9 - 11 on Arduino, PWM 0 - 5 on Wiring) can be pulsed using the analogOut() command, like so:

analogWrite(pin, pulsewidth);

Pin refers to the pin you're going to pulse

Pulsewidth is a value from 0 - 255. 0 corresponds to 0 volts, and 255 corresponds to 5 volts. Every change of one point changes the pseudo-analog output voltage by 5/255, or 0.0196 volts.

...and yes, you have to connect GND as well, not just pin 9.

void loop()
{
 digitalWrite(ledPin, HIGH);
 delay(2000);
 digitalWrite(ledPin, LOW);
 delay(1500);
}

Well, it's PWM, but with a frequency of only 286mHz. ;)

How do you calculate the Hz?

So I connect the Arduino GND to the circuit GND? they are running different power supplies....is it ok to do so?

So I connect the Arduino GND to the circuit GND? they are running different power supplies....is it ok to do so?

Not merely OK, it's essential.

How do you calculate the Hz?

You had a total cycle length of 1500 + 2000 milliseconds = 3.5 seconds. 1 / 3.5 = 0.286Hz = 286mHz

Not merely OK, it’s essential.

See why here:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

If I use digitalWrite I need to figure the Hz but if I am using analogWrite isn't this doing all the job by it self? I mean I connect the Arduino to my 3406 and then if I do lets say analogWrite(ledpin, 256) it sets is to 100% duty cycle. If I take the value down by half then it is 50% duty cycle right? It mimicks PWM? :-?