led control

Hey All, I’m back! been a while and I’m rusty, very rusty. (ALSO CANT FIND THE CODE OPTION IN THE NEW POST.BUT I PUT THE FILE AS AN ATTACHMENT)

I’m trying to blink at this time two separate common cathode RGB LEDs.
I want to be able to choose what led to blink at x frequency.

Normally on a delay, it would be like this

{Right code, wrong tag; you wanted code vs quote. It’s the </> button above

const int LED1R = 11;
const int LED1B = 12;
const int LED1G = 13;

const int LED2R = 10;
const int LED2B = 8;
const int LED2G = 9;

// the setup function runs once when you press reset or power the board
void setup() {
  
  pinMode(8, OUTPUT);
   pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
     pinMode(11, OUTPUT);
      pinMode(12, OUTPUT);
       pinMode(13, OUTPUT);
        
         
}

// the loop function runs over and over again forever
void loop() {

  /*
   
   digitalWrite(LED1R, HIGH);   
  digitalWrite(LED1B, HIGH);  
  digitalWrite(LED1G, HIGH);  
  digitalWrite(LED2R, HIGH);  
  digitalWrite(LED2B, HIGH);  
  digitalWrite(LED2G, HIGH);  
  
  delay(1000);                       
  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  delay(1000); 
  
*/

  digitalWrite(LED1R, HIGH);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(100);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100);
 
  digitalWrite(LED1R, HIGH);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(100);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100); 

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, HIGH);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(100);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100); 
  
  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, HIGH);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(100);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100);
//--------------------------END OF RED

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, HIGH);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(100);
  
  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, HIGH);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(100);
  
  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, HIGH);  
  digitalWrite(LED2G, LOW);  

  delay(100);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100);
  
  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, HIGH);  
  digitalWrite(LED2G, LOW);  

  delay(100);
  
  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);
  
  delay(100);
  //---------------------END OF BLUE

  digitalWrite(LED1R, HIGH);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, HIGH);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(150);
  
  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, HIGH);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, HIGH);  
  digitalWrite(LED2G, LOW);  

  delay(150);


  digitalWrite(LED1R, HIGH);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, HIGH);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(150);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, HIGH);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, HIGH);  
  digitalWrite(LED2G, LOW);  

  delay(150);


  digitalWrite(LED1R, HIGH);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, HIGH);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(150);

  

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, HIGH);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, HIGH);  
  digitalWrite(LED2G, LOW);  

  delay(150);


  digitalWrite(LED1R, HIGH);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, HIGH);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);  

  delay(150);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, HIGH);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, HIGH);  
  digitalWrite(LED2G, LOW);  

  delay(150);

  digitalWrite(LED1R, LOW);   
  digitalWrite(LED1B, LOW);  
  digitalWrite(LED1G, LOW);  
  digitalWrite(LED2R, LOW);  
  digitalWrite(LED2B, LOW);  
  digitalWrite(LED2G, LOW);

  delay(150);

}

This is only 2 RGB LEDs, I’m trying to be able to set up and run almost 40

I’m currently using an uno right now but I have a mega available.

in reality, I only need a chip that can control 5-6 outputs and can communicate with an addressable protocol. Cost in mind what would be the best cost and smallest size?

ill need someone to help me understand the addressing part.

it doesn’t need to be Arduino per se but I’m more familiar with Arduino. (I’m also learning VHDL)

Connect up some shift registers (TPIC6C595 or TPIC6B595), then shift in data from an array as needed. Can do it with an Uno for like 50 cents a shift register vs $20 for a Mega.

Don’t forget current limit resistors.

now, how would I scale that up to up to 48 different LEDs? if each led had an ATMEGA328P-PU on each light and used some comms to tell each one a piece of code? how would I address each?

48 RGB LEDs? Use NeoPixel type LEDs such as ws2812 or apa106. Each led has a controller chip built-in and they communicate using a type of serial data. You can use the AdaFruit NeoPixel or FastLED libraries to allow the Arduino to control them.

do they make those in 30A versions? XD no the LEDs are decided, I need the circuit to control and address them.
i also need to be able to hot swap them, readdress them easily, and a bunch of other things but I'm trying to work at one feature at a time

cminke:
I'm trying to work at one feature at a time

And tell us about one requirement/component at a time?

C'mon, tell us what we need to know to help.

I have :

LEDs, they are 4 color non-addressable.

I'm using a bunch of them in a series-parallel to make one unit (to what I will refer to for now on).

Each unit needs to be addressable and hot-swappable.

The units will be powered and controlled by the main unit, the brain so to speak. Each unit needs to be able to receive and send blinking/PWM information to another. (daisy-chaining) I have 6 wire connectors between units. 2 power, 4 data available. (id like to utilize 2 for Tx/Rx and 2 for independent control when not attached to the brain. )

features needing be relayed; - Brightness (10,50,100)

  • Color Combination (R, G, B, W, G+R [Amber], B+R )
  • Positional Information (what position in the chain is it)
  • Burn Out Detection.
  • Blink Pattern -see note 1-
  • grouping -see note 2-

Note 1- Blink patterns will need to be able to be overridden and real time instantly changed

ex.1 red and blue are flashing at a rate of 504/1001 then once button-X is pushed, sends a command to make led-X, in this case, 1 + 8, change to color-x (color=green) on an always-on pattern.

1R/B - 2R/B - 3R/B - 4R/B - 5B/R - 6B/R - 7B/R - 8B/R

would change to

1sG - 2R/B - 3R/B - 4R/B - 5B/R - 6B/R - 7B/R - 8sG

ex.2 red and blue are flashing at a rate of 504/1001 Then once button-X is pushed, sends a command to make led-X, in this case, 4 + 5, change to color-x (color=white) on a 100/100 alternating pattern.

1R/B - 2R/B - 3R/B - 4R/B - 5B/R - 6B/R - 7B/R - 8B/R

would change to

1R/B - 2R/B - 3R/B - 4W - 5W - 6B/R - 7B/R - 8B/R

note 2- each couple of LED's can be "grouped" together to make it easier to manage the large quantities. 30 units max in one group. up to max 8 groups for a total of 240 LED units total. like I initially said max 42 because id like to have headroom for a few simple single color, on/off units in a group.

any question?

Holy Gorgonzola, Batman!

If you pull this off you will deserve a degree in electronics and electrical engineering.

It sounds like a theatrical lighting system. Hasn't this wheel already been invented? There's a well-known protocol for commanding lighting systems. Not being a theatrical type, I can't remember what is called, but there are forum members who, if not experts, are familiar with it. A bit like MIDI for lighting.

And all these LEDs need 30A each? Serious stuff.

there led per se haven't been decided but they are high current draw, between 2 and 30 A at varying voltages. they are very high brightness.

dmx is an option for sure. just not sure if it's fast enough. and how easy it is to set up into an interfaceable area.

I am in school for electronics engineering :slight_smile: so I take that as a compliment

The only other thought I had was to use ws2811 chips. These are basically the same as the chips inside ws2812 LEDs. Perhaps the chip's outputs could be used to drive MOSFETs to control your large LEDs. 3 potential problems to overcome: 1. large LEDs need constant current circuits, so you would need 3 X CC circuits which included high power MOSFETs; 2. ws2811 has 3 outputs and you need 4, but perhaps there is a 4-channel equivalent; 3. I guess the distances between your LEDs will be significant, so line drivers might be needed to transmit the serial data from one light to the next.

okay well, I’m thinking can all this be done with some kind of atmega? I know I can do what I need to do on each individual chip with an Arduino uno(), the ATMEGA328-PU is only 2.45 a chip and I have a couple of chips available to me to use and test with, that should be enough to test, I have an ATmega2560 here as well that could be used at the main controller for now.

so I’m guessing id use pins 1,0 to Tr and Rx between Arduinos but can it address and parallel with others or would i need one out for each Arduino?

i know the mega has 4 Tx/Rx channels and id like to comms with 2 artmega328 chips on each line

Maybe you should look into RS485 serial protocol. I've never used it myself but it's supposed to be good for making a serial network with many nodes over longer distances.

Hi,
If you are going to use non-addressable, common Cathode Leds, what are you going to use to control the current to each individual LED?
Common cathode means you will have to HIGH SIDE switch and if you use a multiplexer, it will have to SOURCE the LED current.

Tom... :slight_smile:

TomGeorge:
Hi,
If you are going to use non-addressable, common Cathode LEDs, what are you going to use to control the current to each individual LED?
Common cathode means you will have to HIGH SIDE switch and if you use a multiplexer, it will have to SOURCE the LED current.

Tom… :slight_smile:

the LEDs are actually completely isolated, I can either have them driven common anode or common cathode.

here are the details of one led
R G B W
VF min 2.3 | 3.0 | 3.0 | 3.0 V
VF max 3.6 | 3.9 | 3.9 | 3.9 V
Minimum Current 5 - 0.1 | 0.1 | 0.1 | 0.1 A
Maximum Current 5 - 2.0 | 2.0 | 2.0 | 2.0 A

also im open to driver options. ive been looking at a Nex-FET by Tx instruments. they seem to be the best bang for the size of package. some can handle 30-50 amps

so I've finally started doing some hands-on stuff and I have 2 unos and one mega.

the mega will be my master sender and the unos both as slave revivers.

my questions are,

where inside the Master code do I input the if statement for a button press to trigger a Library(full of blinks for led pins)

is it possible to address the chips from the master without changing the slave code manually?
basically, I want to be able to ake a code that says

if I have 2 LEDs and then plug in two more slaves, that it changes the patterns to include the new slaves positionally. or do I have to assign each one?

if thats the case id have to look into a serious program with an interface to "rearrange" the leds placement.

i have ideas for that but im not fluent with code yet. tying to learn but theres just so much information.

where inside the Master code do I input the if statement for a button press to trigger a Library(full of blinks for led pins)

In loop(). At this stage that's all I can say. Where would you put the word "if" in a novel? You can't put it in some random place, it wouldn't make any sense. Same for code.

is it possible to address the chips from the master without changing the slave code manually?

Yes. Or it could be. But you have not decided yet how your slaves will be connected to the master, or each other, or what protocol they will follow.

I think I2C would be the best as Id like to minimize the required connections. 2 wire would be the best for me.

To make sure I'm clear I want to have many led lights controlled as slaves. Their default address would be either "0000000000000" or a random address. Once the lights get a signal they would assign themselves an individual address that is unique to that specific slave.

if that's not a perceivable option then I could always give each slave a custom address that can be received by the master and then sends a command back to it.

2 wire would be the best for me.

Oh, ok. I thought you came here for advice. But if you already know what's best, you don't need any. So all your lights will be less than a metre away from a central controller? Fine, use 2 wire.

is that a real limitation of i2c? never seen anything about that so that's good to know! is there anything else that i could use a 2 wire system to cover a maximum of 25M?