Controling LED's with Arduino and Mosfets

Thread Starter

DiogoMM

Joined Jun 9, 2021
2
Im knew to eletronics and arduino programing, and I have a complex first project:
My idea is to control the brightness of about 26 ,1Watt Led's with arduino using mosfets. The LED's will react to sound feed coming from MAX MSP.

I have a couple of questions:
.What is the best way of powering up the LED's (these have a working voltage of 3.2 to 3.4 volts and a forward current of 700mah).What power suply should i buy and whats the best way to conect them;
. Also there is a limit of how much mosfets can be powered by an arduino, firstly due to its limited PWM ports, but also due to power. How can i solve this since i have 26 leds to control individuali (when the brightness of one LED is at max the following LED in the row lights up, reacting to the Max Msp sound amplitude feed);

Thank you,
DiogoM.
 

Irving

Joined Jan 30, 2016
1,526
There are many ways to extend the number of output ports on an Arduino, but first you need to clarify how the LEDs are going to work. Is it 26 individual LEDs or groups of them or what? You need to be precise about this. Draw diagrams showing sequences or whatever is meant to happen.

As to powering them, much will depend on how many are lit at once and how bright. Worst case you will need a supply capable of 26 * 0.7A, say 20A at a suitable voltage. But again this will depend on how the LEDs are arranged. So get that right and the rest follows easily...

If you have data sheet or link for the LEDs that will be useful.

Oh, and welcome to AAC!
 

Thread Starter

DiogoMM

Joined Jun 9, 2021
2
Thank you for your answer,
*The LED are 3watt not 1watt**

The idea is to have them individuali controled, I could say that they would make almost a starry night effect. They pulse/get bright to the intensity of volume(within Max, there are 26 players each assign to control one led each using the sound amplitude).
I would like them to be at full brightness too as they will bee inside glass bottles.

I couldnt find the led data sheet but here's the Amazon link to some similar ones:
https://www.amazon.co.uk/Haobase-5pcs-Power-White-Light/dp/B01EW79IPY

As I am knew to this, I have difficulties making the esquematics but I took a shot at it.(probably is very wrong and it doesnt work but thats why im here)Its basicly that but times 26,I know it needs some resistors too.
1623230438989.png
Thank you again,
DiogoM.
 

Yaakov

Joined Jan 27, 2019
3,155
Just a small correction:
The current rating of the LEDs is in mA, not mAH which is a battery rating

The “H” is time in hours and is not relevant to LEDs since it indicates capacity not load.
 

BobTPH

Joined Jun 5, 2013
3,315
A rating of an LED in mAH could be interpreted as a reliability measure.

Perhaps 50% fail after 1 hour at 700 mA?

Bob
 

geekoftheweek

Joined Oct 6, 2013
641
The lack of PWM is fairly easy to get around in program. I have an update to a similar led project in the works myself. I haven't used Arduino myself yet (just PICs), but it shouldn't be hard to work it out. I'll try to describe best I can.

In the initial setup:
Code:
int pwm_count = 255;
int current_leds[26] = {0};
int saved_leds[26] = {0};

// also set up a timer, and an interrupt routine for the timer.
In the timer interrupt:
Code:
pwm_count --;
if (!pwm_count)  {  // pwm count is zero... turn on leds as needed
     for(i =0; i < 26; i++) {
          if (saved_leds[i]) --> turn on LED[i];  // only turn on the LED if it is not zero
          current_leds[i] = saved_leds[i];
     }
}
else {
     for(i =0; i < 26; i++) {
          current_leds[i]--;
          if (!current_leds[i]) --> turn off LED[i];  // led count equals zero... turn off the led
     }
}
Unfortunately in my project I have enough pins to run all 12 LEDs in my set. You could either find an Arduino with enough pins, or instead set up a few bytes to be sent to some shift registers to control your mosfets. I would think you could get the timing quick enough to not see it.

Just a thought.... if your design will allow for it find a way to sandblast the bottles. Even a little bit will help diffuse the light and make the whole bottle glow to some extent.
 

djsfantasi

Joined Apr 11, 2010
7,693
The lack of PWM is fairly easy to get around in program. I have an update to a similar led project in the works myself. I haven't used Arduino myself yet (just PICs), but it shouldn't be hard to work it out. I'll try to describe best I can.

In the initial setup:
Code:
int pwm_count = 255;
int current_leds[26] = {0};
int saved_leds[26] = {0};

// also set up a timer, and an interrupt routine for the timer.
In the timer interrupt:
Code:
pwm_count --;
if (!pwm_count)  {  // pwm count is zero... turn on leds as needed
     for(i =0; i < 26; i++) {
          if (saved_leds[i]) --> turn on LED[i];  // only turn on the LED if it is not zero
          current_leds[i] = saved_leds[i];
     }
}
else {
     for(i =0; i < 26; i++) {
          current_leds[i]--;
          if (!current_leds[i]) --> turn off LED[i];  // led count equals zero... turn off the led
     }
}
Unfortunately in my project I have enough pins to run all 12 LEDs in my set. You could either find an Arduino with enough pins, or instead set up a few bytes to be sent to some shift registers to control your mosfets. I would think you could get the timing quick enough to not see it.

Just a thought.... if your design will allow for it find a way to sandblast the bottles. Even a little bit will help diffuse the light and make the whole bottle glow to some extent.
The Arduino Mega has up to 54 digital IO pins, so that may help.
 

geekoftheweek

Joined Oct 6, 2013
641
I just noticed something I missed...

In the timer interrupt:
Code:
pwm_count --;
if (!pwm_count)  {  // pwm count is zero... turn on leds as needed
     pwm_count = 255; // reset pwm count -- not in the first version
     for(i =0; i < 26; i++) {
          if (saved_leds[i]) --> turn on LED[i];  // only turn on the LED if it is not zero
          current_leds[i] = saved_leds[i];
     }
}
else {
     for(i =0; i < 26; i++) {
          current_leds[i]--;
          if (!current_leds[i]) --> turn off LED[i];  // led count equals zero... turn off the led
     }
}
pwm_count = 255; -- don't forget to reset the counter
 

Irving

Joined Jan 30, 2016
1,526
@DiogoMM can you explain how you plan to use Max MSP on this? As far as I can see its a 'visual programming language' for audio so presumably you're going to take audio from an analog input somewhere (where?) and link this in some way that's still unclear to the LEDs? I think we need more detail on this... Further reading here https://slab.concordia.ca/arduino/arduino-max/ suggests MAX MSP is running on another machine (PC?) and communicates to the Arduino by a USB Serial connection and some software that implements a 'DigitalOut' function on the Arduino. The data rate between MAX MSP and Arduino suggests there are only 100 samples/sec

My immediate concern is that it is extremely unlikely that a basic Arduino has sufficient computing 'grunt' to handle 26 PWM 'brightness' digital outputs and communicate serially...
 
Top