# Help with Arduino PWM LED driver

#### roof

Joined Jan 8, 2016
18
Hi folks, it's my first thread in this forum.
Version 1.
I'm in a phase of my construction when it stop up. This circuit using Arduino Nano USB, 2 green LED, 2 red LED, all 3W, 700mA, red 2,5V, green 3,5V Vcc. It's a pilot strobe flasher for UVA/Drone using. When power on, green led 1 & 2 flash approx. 200mS, one by one. This repeat each 3 sec. 4 sec. after power on, red led 3 & 42 flash approx 200mS. 200mS ON, give a strong light effect, like strobe. By this delay, green led flash each 3 sec, while red flash each 4. sec.

This url link is my first diagram:
http://schematics.com/project/flash-light-arduino-buck-per-181015-1-22344/

Version 2:
When thinking about each grams in weight count, and will decrease flight time, something has to be done. I skip the MOSFET array IC, I change step down converter (to adaptive correct voltage for LED's), to PWN 700mA constant drivers for LED. This drivers are quite best in use, when it comes to constant current flow, because of this 3W led change it's properties when heated, moisture etc. Driver provides a constant current drive @ 700mA. QUESTION are so, how to controlling PWM frequency to provide 2.5 volts and 3.5 volts to LED's?

I need help both to Arduino wiring diagram (see Annex No. 2, one attempt with the approach of schematic wiring) and reprogram my Sketchup. Uploading my Sketchup as it is today, but must be changed to charts ver. 2.

PWM LED driver: http://www.ebay.co.uk/itm/121812186146?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT

3W LED type: http://www.ebay.co.uk/itm/261648843386?_trksid=p2057872.m2749.l2649&ssPageName=STRK:MEBIDX:IT
Connectors:

Ver. 1.0

Ver 2.0

Arduino Sketchup for ver 1.0
Code:
const int ledPin1 =  13;      // Set pin's in use :
const int ledPin2 =  12;
const int ledPin3 =  11;
const int ledPin4 =  10;

// Variables will change :
int ledState1 = LOW;             //
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 95;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
// set the digital pin as output :

pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
}
void loop()
{

do
{
unsigned long currentMillis = millis();

if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa :
if (ledState1 == LOW ) {
ledState1 = HIGH;
ledState2 = LOW;
}
else {
ledState1 = LOW;
ledState2 = HIGH;
count++;
// set the LED with the ledState of the variable :
}
digitalWrite(ledPin1, ledState1);
digitalWrite(ledPin2, ledState2);
}
} while (count < 2); //sets how many blinke :
ledState2 = LOW;
digitalWrite(ledPin2, ledState2);
count = 0;
//=========================================================
delay(1000); // PAUSE and sets the time beteewen set green and read
//=========================================================
do
{
unsigned long currentMillis = millis();

if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa:
if (ledState3 == LOW) {
ledState3 = HIGH;
ledState4 = LOW;
}
else {
ledState3 = LOW;
ledState4 = HIGH;
count++;
// set the LED with the ledState of the variable:
}
digitalWrite(ledPin3, ledState3);
digitalWrite(ledPin4, ledState4);
}
} while (count < 2);
ledState4 = LOW;
digitalWrite(ledPin4, ledState4);
count = 0;
//=========================================================
delay(1400);  //sets the time beteewn set green and read
//=========================================================
}

#### sailorjoe

Joined Jun 4, 2013
363
Roof, first problem I see is that an important input to your LED driver circuits is missing. This is in Version 2.0. The units need I+ and I- connected. In your case, most likely, I- should be connected to ground. But it's hard to tell because you don't label the input and output pins with signal names, just pin numbers. That doesn't tell me very much.
Now, the Arduino Nano outputs should be set up as PWM signals, so you can control the brightness, and these should be connected to the PWM inputs on the LED drivers. If you don't want to to control the brightness, just strobe the lights on/off, then fine just drive the PWM signal as an on/off pulse.
I believe that is what your code is doing, so it should be OK.
Your code seems OK to me after reading it just one time.

#### dannyf

Joined Sep 13, 2015
2,197

1. you provided lots of information, not much of it is helpful to people who want to help you;
2. you may have to play with the led driver modules a little. looks like it takes a pwm input signal. If that's the case, you are golden.

#### roof

Joined Jan 8, 2016
18
(Thanks to moderator, as move my thread )
Sailorje,
Are you for sure this LED driver are missing an input in the trigger input? To me it make sense, this device could be driven by negative or positive input pulse. Not correct? Well, if I use a full voltage output from Arduino, this value is 5 or 0. 5 volts to the LED is too much, and just hang on a 3W resistor voltage dealer, not a good solution. The purpose of the constant current Controll disappears. I'm not for sure, if I insert a spanning parts resistance in series with the output from the Arduino, two this PWM module, do I Obtain output Vcc or some lower voltage level?
"But it's hard to tell Because you do not label the input and output pins with signal names, just pin numbers. That does not tell me very much." If you take a look at the Arduino Nano device, it should give you information, see URL here, above pinout here: http://www.keywild.com/arduino/gallery/Nano_PinOut.png

The code are not composed of PWM, only on / off, my schematic drawings showing how to insert variiable resistances which creates pulse mode cycle, but this addition is missing in sketchup. The code you see is NOT made by me, but by Arduino our friend, as opposed to me, is super good, I'm a newbie.

To Danyf; What is it you miss, unlike you, I tell complementary what I know and do not let it be up to me to guess. Please, be more explanatory.

#### shteii01

Joined Feb 19, 2010
4,644
So... we do the design, we do the programming and we get what for all that work?

#### roof

Joined Jan 8, 2016
18
Do not think shteii01 have sense of orientation in order? As you will see, it lacks a Sketchup additional PWM, everything else is arranged. If you feel a waste of time and "money", throw then not waste time on frayed comments.

#### djsfantasi

Joined Apr 11, 2010
7,763
Your sketch does not use PWM currently, as you stated. Not all pins on an Arduino capable of PWM also. Fortunately, your sketch is using the correct pins for PWM.

Instead of using the command digitslWrite(), you need to use analogWrite(). This command takes duty cycle as its second parameter instead of state. Duty cycle is a value from 0 to 255, where 255 is 100% on.

If you supply is 5VDC and you need 2.5V, use a 50% duty cycle. This is a value of 127 in analogWrite.

The sketch will keep the signal outputting with the specified duty cycle, until you change it. This to shut it off, use a duty cycle of 0.

Your existing sketch can be easily modified to use analogWrite() in the sketch structure. Just change the meaning of the ledStatex variables.

#### roof

Joined Jan 8, 2016
18
Djsfantasi, LOVELY! Thats mean, not necessary to use vari pot. resistor? Just set in parameters, as fit to my needed out voltage. Vcc is 12.0V. So with value 1-255, should be easy to set parameters level for 2,5V and 3,5 V. Thanks a lot!

#### djsfantasi

Joined Apr 11, 2010
7,763
I don't see a need for a pot.

However, looking at your diagram, I noted the pins you are using. They don't all support PWM on the nano. Look at the pin out diagram. Pins 6,8,9,12-14 may be used for PWM. Your LEDs need to be connected to one of those pins.

Also, remember the current limitations from an Arduino pin. It is a maximum of 40mA. I don't get what the boxes before the LEDs do, so I don't know their current draw.

Note that just to be confusing, the nano pin numbering scheme is different than the digital pin labeling scheme. Use the nano pin numbers! Remembering that D09 is pin 12 is tough. Just use pin 12.

Last edited:

#### shteii01

Joined Feb 19, 2010
4,644

#### roof

Joined Jan 8, 2016
18
I thought when I look at the diagram for Nano, I was using PWM pins output. 6,8,912, and 14 are PWM. So using 30 as +12V, and 20 as GND. Because of this circuit befor LED, this have a high input resistance, so because of this this PWM power constant DC-DC driver will not load Arduino its max load of 40mA. Simultaneously deliver this constant current of 700mA, 3W LED. A constant current driver is the best component for a 3W LED to use this to component. The LED's internal properties can easily change, and variable current will be required to ensure LED life condition, at worst, prevents this for burning off. This is the circuit's intended use.

Maybe you also noticed in the schema, a circuit between the battery source and Arduino? With different causes, a Li-Po battery 1500mAh 11.1 volt source weighs 132 grams. Therefore I used two Li-Ion 18650 3.6V 3300mAh X2, in series = 106 grams including battery box. This provides approximately 7.6 volts, close to being too low drive voltage for my PWM, = min. 7.0V. This step up converter (Buck)) converts 7.6 volts to 12.0 volts (max 2A)

#### sailorjoe

Joined Jun 4, 2013
363
(Thanks to moderator, as move my thread )
Sailorje,
Are you for sure this LED driver are missing an input in the trigger input? To me it make sense, this device could be driven by negative or positive input pulse. Not correct? Well, if I use a full voltage output from Arduino, this value is 5 or 0. 5 volts to the LED is too much, and just hang on a 3W resistor voltage dealer, not a good solution. The purpose of the constant current Controll disappears. I'm not for sure, if I insert a spanning parts resistance in series with the output from the Arduino, two this PWM module, do I Obtain output Vcc or some lower voltage level?
"But it's hard to tell Because you do not label the input and output pins with signal names, just pin numbers. That does not tell me very much." If you take a look at the Arduino Nano device, it should give you information, see URL here, above pinout here: http://www.keywild.com/arduino/gallery/Nano_PinOut.png

The code are not composed of PWM, only on / off, my schematic drawings showing how to insert variiable resistances which creates pulse mode cycle, but this addition is missing in sketchup. The code you see is NOT made by me, but by Arduino our friend, as opposed to me, is super good, I'm a newbie.

To Danyf; What is it you miss, unlike you, I tell complementary what I know and do not let it be up to me to guess. Please, be more explanatory.
Roof, Let me try to be more clear on what I think is missing. You have an LED driver circuit, and it has 7 pins. On your schematic, you only have four pins numbered for the LED driver, but no way to tell which pin on the schematic matches the pin on the module. I can guess some of the pins because they're pretty obvious, like LED+ on Pin 3 and LED- on Pin 4. Pin 2 is probably I+ on the module. That leaves Pin 1, which is either PWM or I-. I can't tell which.

In my opinion, I- should be connected to ground. Your Arduino logic signal should be tied to the PWM pin on the LED driver. If that's what you have, great, but then where is I- connected?

#### roof

Joined Jan 8, 2016
18
Tak a lokk at this, my Chinese co operated company write in an answer, how it works(?):

Now We have get solution to your question.

Board lights on a serial link to the LED+ and LED-pins;
Links to IN+ and IN-input voltage, working in the buck mode to ensure total pressure difference lower than the input voltage of the LED 2-3V to work.
You can IN-and links to Arduino PWM pin GND and digital I/O, output of the PWM signal to control the LED brightness.
PWM maximum signal frequency: 20HZ-20KHZ
Rated proposal: 1KHZ

Some sense?

#### djsfantasi

Joined Apr 11, 2010
7,763
The voltage supply, pin 30, is input to a voltage regulator to provide the Arduinos 5V operating voltage. Your output pins will provide 5V maximum. To provide a higher PWM voltage, you'll have to supply a second voltage source, tie it ground to the Arduino ground, drive it through a transistor or MOSFET. The Arduino will not supply more than 5V.

Also, note that pins 6,8,9,12,13,14 all can be used for PWM. As such, they are an output. In your second diagram, I see them as an input, from a pot.

I think there is some confusion as to what PWM is and how your constant current "boxes" are used (where is the power for the LEDs?)

Is this the case?

Last edited:

#### roof

Joined Jan 8, 2016
18
Well, my Vcc are +12V. So pins 30 should be the right + in voltage, i think. I did not need any + 5 volt in my schematic diagram. See diagram Nano, pin 30 "SUPPLY VOLTAGE IN-7 - 12 V DC. Well, to adjust brightness as a dimmer, the pot vario resistance can be used to adjust the PWM duty cycle, but it's also a possible to set this as permanent value, due to your text: This command takes duty cycle as its second parameter instead of state. Duty cycle is a value from 0 to 255, where 255 is 100% on. I found @ Vcc 12 volts, the value for 2,5 volts are approx. 53.125,-3,5 volts=74,375. So, potmeters are not longer needed to use, when I set this permanent value, for a permanent PWM duty cycle.

... (where is the power for the LEDs?) This power are created using DC-DC constant current drivers, 1-4. This driver's are supplies with +12V, GND. As I told you before here.

#### sailorjoe

Joined Jun 4, 2013
363
Tak a lokk at this, my Chinese co operated company write in an answer, how it works(?):

Now We have get solution to your question.

Board lights on a serial link to the LED+ and LED-pins;
Links to IN+ and IN-input voltage, working in the buck mode to ensure total pressure difference lower than the input voltage of the LED 2-3V to work.
You can IN-and links to Arduino PWM pin GND and digital I/O, output of the PWM signal to control the LED brightness.
PWM maximum signal frequency: 20HZ-20KHZ
Rated proposal: 1KHZ

Some sense?
Sorry, I don't understand the explanation. Let me ask it this way. Where is the ground line (I-) for the LED driver module shown on your schematic? Which PIN number is it? Also, which PIN number on the LED driver module on your schematic is the PWM signal?

#### roof

Joined Jan 8, 2016
18
The explanation was some puzzled for me to catch, also. There is no ground line for the load side. Probably it like this, IN- to GND Arduino. the I/O from Arduino as PWM out pin to IN+. Correct? The pin no for LED in my schematic are not set up, but I make some change in a while.

#### sailorjoe

Joined Jun 4, 2013
363
The explanation was some puzzled for me to catch, also. There is no ground line for the load side. Probably it like this, IN- to GND Arduino. the I/O from Arduino as PWM out pin to IN+. Correct? The pin no for LED in my schematic are not set up, but I make some change in a while.
OK, I'll wait.

#### sailorjoe

Joined Jun 4, 2013
363
Thanks, Roof. OK, your schematic still doesn't have I- connected to GND, and that's a problem. I don't know where the current is going, but probably through the PWM pin for each driver. Eventually, your nano is going to fry, or maybe the driver module will fry. So please connect I- to GND.
Djsfantasi has already indicated how to use PWM in your Sketch to control on/off and brightness, if that's something you need to do. It can be useful to balance the red and green light pulses.