Help a Novice with an LED design or system PLEASE

OK, so you essentially have "bare" LEDs for the street lights and will be using plain LEDs for the buildings. Perfect!

So, a MAX7219 module will control up to sixty-four of them wired in a matrix, operating from 5 V and you do not need resistors as the MAX7219 controls the current for you. It will control, each LED individually but the brightness of all (which are switched on at any one time) together.

Sixty-four would probably cover all of your LEDs, but in case it did not, these are chain-able - you can use two, three, four, eight in a row, connected from the same control pins on the Arduino. Actually, if you use significantly fewer LEDs, you do not need all eight columns of the matrix and the LEDs will be a little brighter when you program the chip accordingly.

Here is a diagram of the internal connections of that LED matrix itself, to indicate how you would wire your LEDs to correspond:

Please do not buy an Arduino UNO - they are not suitable for construction projects such as this. :astonished: You want a "Nano" which comes with connection pins supplied, but for this, you would instead solder wires directly to the terminals.

Click for eBay supplier.

Here is a MAX7219 matrix module:

Click for eBay supplier.

It comes with an 8 by 8 LED matrix because the intended purpose is to generate patterns, but because you do not want that but rather to use your own matrix of LEDs, you just use the module to implement your own wiring; the MAX7219 is already mounted.

All this part will be powered at 5 V. The Arduino board cannot regulate 12 V to 5 V for you, you either use a regulated 5 V supply such as a "phone charger", or a step-down "buck" regulator (cheaply available on eBay) from your 12-16V supply.

I leave you to the other comments regarding strip lighting, but the controllable LEDs are easy!

Please do not buy an Arduino UNO

Actually getting an UNO for initial learning and checking simple ccts. is quite okay.
Since the cost of having one is reasonable and plugging simple wires into the headers while testing is convenient, new users may find an UNO easy to use and understand.

The final hardware for the project can easily adapted to a NANO or ProMini.
Dupont headers/cabling plugged into an UNOs header is an easy and effective way to wire them (UNOs) into a final projects driver board.

For new users, it could be argued that the I/O heavy Mega is good to have simple one to one connections to LEDs, switches and transistor drivers etc.
New users may benefit from ‘not’ using multiplexing hardware, and may find it easier to trouble shoot problems.

.

larryd:
For new users, it could be argued that the I/O heavy Mega is good to have simple one to one connections to LEDs, switches and transistor drivers etc.

How many LEDs?

Microcontroller ATmega2560
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limit) 6-20V
Digital I/O Pins 54 (of which 15 provide PWM output)
Analog Input Pins 16
DC Current per I/O Pin 20 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 256 KB of which 8 KB used by bootloader
SRAM 8 KB
EEPROM 4 KB
Clock Speed 16 MHz
LED_BUILTIN 13
Length 101.52 mm
Width 53.3 mm
Weight 37 g

And of course, for an application like this, several street light LEDs can be controlled by a single I/O pin.

.

larryd:
And of course, for an application like this, several street light LEDs can be controlled by a single I/O pin.

How many can be controlled by a single I/O pin at 20 mA each? How many can be lit simultaneously?

“How many can be controlled by a single I/O pin at 20 mA each? ”

When driven by an I/O pin which controls a MOSFET, quite a few.

Never suggested an Arduino I/O pin couldn’t be connected to a driver.

Example:
Using a MOSFET that can sink 500mA that would give 25 @20mA LEDs.

The OP will have to decide what will work on his setup.

.

@Tomwhite1124

If you are not familiar with LEDs here is some information:

Its short code for dimming leds. very easy.
You need remember that this code I cut from my code, and You need change it to Your needs.

void slide(int a) // I know, wird name, but it remind me a potentiometer
{
  for (unsigned short i = 0; i < 255; i++)
  {

      if ( ledrgb[i] < a ) // check led value if is smaler from random
      {
        ledrgb[i] += 1; // add 1 to array (slide potentiometer to the left) <-- Change this value to speed up
      }
      else if ( ledrgb[i] > a ) // check led value if is bigger from random
      {
        ledrgb[i] -= 1; // take 1 from array (slide potentiometer to the right) <-- Change this value to speed up
      }
      else
      { // do nothing means values are equal to a number
      }


  }
  // You can coment/uncoment this to see how array numbers are changing
  //  printstring(); // print what was changing

}

Next one code is very advanced, and is taking almost all memory of arduino.
But this code is using on computers to display movies, picture correction and many other things.
Advantage of this code is that You can use only one value to change all colors from 0 to 360 degree.
I propose using this easy one.

#include <IRremote.h>

  float h, v, s, hi, si;
  float f, p, q, t;
  float r, g, b;
  int ri, gi, bi;

  int RECV_PIN = 2;
  IRrecv irrecv(RECV_PIN);
  decode_results results;
  
  long value;
  bool getvalue = false;
  bool autodim = false;
  short ledspeed = 1;
  short autospeed = 100;
  short driverspeed = 10;
void setup()
{
  //Serial.begin(9600);
  
  Serial.println("Enabling IRin");
  irrecv.enableIRIn();    // Start the receiver
  Serial.println("Enabled IRin");
  
  pinMode(9, OUTPUT);  // Pins for Arduino pro mini Atmega 168 (5V, 16MHz
  pinMode(6, OUTPUT);
  pinMode(5, OUTPUT);
   
  h = 1; v = 1.0; s = 1.0;
 
}
  int j = 0;

void RGBdriver()
{

  if (s < 0) { s = 0; }
  if (s > 1.0) { s = 1.0; }
  if (v < 0) { v = 0; }
  if (v > 1.0 ) { v = 1.0; }
  if (h < 0) { h = 0; }
  if (h > 359 ) { h = 360; }
  delay(driverspeed);
     hi = h / 60; // sector 0 to 5
     si = s;
  Serial.println(hi);
    int i = int(hi);
  
    f = hi - i; // factorial part of h
    p = v * (1 - si);
    q = v * (1 - si * f);
    t = v * (1 - si * (1 - f));
     
    switch(i) {
        case 0:
            r = v;
            g = t;
            b = p;
            break;
     
        case 1:
            r = q;
            g = v;
            b = p;
            break;
     
        case 2:
            r = p;
            g = v;
            b = t;
            break;
     
        case 3:
            r = p;
            g = q;
            b = v;
            break;
     
        case 4:
            r = t;
            g = p;
            b = v;
            break;

        case 5:
            r = v;
            g = p;
            b = q;
            break;
     
        default: // case 5:
            r = v;
            g = t;
            b = p;
    }

  ri = r * 255;
  gi = g * 255;
  bi = b * 255;

  Serial.print(" h = "); Serial.println(h);
  Serial.print(" v = "); Serial.println(v);
  Serial.print(" s = "); Serial.println(s);
  
  Serial.print(" r = "); Serial.println(ri);
  Serial.print(" g = "); Serial.println(gi);
  Serial.print(" b = "); Serial.println(bi);
  
  ri = 255 - int(ri);
  gi = 255 - int(gi);
  bi = 255 - int(bi);
  

  
  analogWrite(9, ri);
  analogWrite(6, bi);
  analogWrite(5, gi);
}

  
void loop()
{
    if (irrecv.decode(&results)) 
  {
    Serial.println(results.value);  // result is in decimal value. Is posible to set HEX or BIN
    // also printing on serial screen is usefull to add new keys.
    
    value = results.value;      // variable Value is used later in menu.
    getvalue = true;      // getvalue variable is used as the gate for switch statment 
    // Switch case is used only once after resiving data from IR reciver. Untill next button will be activated
    
    delay(100);
    irrecv.resume(); // prepare for Receive the next value
  }

    if ( getvalue == true)      // if true, gate is opened and switch statment is made
  {
    switch (value)
    {
      case -1: break;   // do nothing
      
      // importand, I use diferent keyboard for IR reciver. If You use keyboard from arduino package
      // You need see what key numbers serial monitor is showing on. And then change in case statment

// RED 0
      case 16738455: autodim = false; /*h = 1;* v = 0.2; s = 1.0;*/
      if ( h > 0 ) { for ( h; h >= 0; h -= ledspeed) { RGBdriver();}} 
      break; //red
// BLUE 120      
      case 16750695: autodim = false; /*h = 120;* v = 0.2; s = 1.0;*/
      if ( h < 120 ) { for ( h; h <= 120; h +=ledspeed) { RGBdriver();}}
      if ( h > 120 ) { for ( h; h >= 120; h -=ledspeed) { RGBdriver();}}
      break;    // green
// Green 240      
      case 16756815: autodim = false; /*h = 240;* v = 0.2; s = 1.0;*/
      if ( h < 240 ) { for ( h; h <= 240; h +=ledspeed) { RGBdriver();}}
      if ( h > 240 ) { for ( h; h >= 240; h -=ledspeed) { RGBdriver();}}  
      break; // blue
// Gold 60
      case 16724175: autodim = false; /*h = 240;* v = 0.2; s = 1.0;*/
      if ( h < 60 ) { for ( h; h <= 60; h +=ledspeed) { RGBdriver();}}
      if ( h > 60 ) { for ( h; h >= 60; h -=ledspeed) { RGBdriver();}}  
      break;

// Cyian 180
      case 16718055: autodim = false; /*h = 240;* v = 0.2; s = 1.0;*/
      if ( h < 180 ) { for ( h; h <= 180; h +=ledspeed) { RGBdriver();}}
      if ( h > 180 ) { for ( h; h >= 180; h -=ledspeed) { RGBdriver();}}  
      break;

// Blue Green 140
      case 16743045: autodim = false; /*h = 240;* v = 0.2; s = 1.0;*/
      if ( h < 140 ) { for ( h; h <= 140; h +=ledspeed) { RGBdriver();}}
      if ( h > 140 ) { for ( h; h >= 140; h -=ledspeed) { RGBdriver();}}  
      break;

// Violet 300
      case 16716015: autodim = false; /*h = 240;* v = 0.2; s = 1.0;*/
      if ( h < 300 ) { for ( h; h <= 300; h +=ledspeed) { RGBdriver();}}
      if ( h > 300 ) { for ( h; h >= 300; h -=ledspeed) { RGBdriver();}}  
      break;

// Blue Red 340
      case 16734885: autodim = false; /*h = 240;* v = 0.2; s = 1.0;*/
      if ( h < 340 ) { for ( h; h <= 340; h +=ledspeed) { RGBdriver();}}
      if ( h > 340 ) { for ( h; h >= 340; h -=ledspeed) { RGBdriver();}}  
      break;
      
// Green Gold 100
      case 16726215: autodim = false; /*h = 240;* v = 0.2; s = 1.0;*/
      if ( h < 100 ) { for ( h; h <= 100; h +=ledspeed) { RGBdriver();}}
      if ( h > 100 ) { for ( h; h >= 100; h -=ledspeed) { RGBdriver();}}  
      break;

      
// manual
      case 16736925: autodim = false;  v = v + 0.05;  RGBdriver(); break;
      case 16754775: autodim = false;  v = v - 0.05;  RGBdriver(); break;

      case 16720605: autodim = false;  s = s + 0.1;  RGBdriver(); break;
      case 16761405: autodim = false;  s = s - 0.1;  RGBdriver(); break;
      
// Atodim
      case 16732845: autodim = true;
      
      default: s = 1.0 ;
      // this choice will stop counting leds intensity.
    }
    Serial.println(value);    // debuging on serial port, helps also to add new choice in menu
    getvalue = false; 
  }
  if (autodim == true)
  {
    if ( j <= 359 )
    {
      j = j + 1;
      h = j;
      Serial.print(" j = "); Serial.println(j);
      delay(autospeed);
    }
  
  else
  {
    j = 0;
    h = j;
  }
    RGBdriver();
  }
}

Thanks all the info guys really appreciate it all and it’s a lot to look into

With regards to the MAX7219 that looks like it could be an easy solution for me with regards to the street lights and interior lighting I’ll try and wire up a matrix of leds in the 8x8 confg the. Extend from that to the lighting on my system I’m u sure if all 8x8 is required for the matrix to work or I fact the MAX7219 so what I planned on doing is completing the matrix with less that won’t be visible but then I can extend the wiring and remove or relocate basically more Leds if and when required on my layout ....

From what information I’ve seen with it though the delay between changing the character or text on the matrix is a delay function can this delay be changed to a timer of some sort in the code .... also if using a mosfet to control the led lighting strip 12v and using a pmw signal to control the brightness can this also be included into the code on the same board so it all works as one as such

Slowly trying to get my head around this haha

Tomwhite1124:
With regards to the MAX7219 that looks like it could be an easy solution for me with regards to the street lights and interior lighting

That is exactly what I was pointing out. Buy one of those cheap modules, forget the matrix display that comes with it, the PCB makes it easy to connect the wires to it and also includes the current control resistor and a small bypass capacitor. You should add a larger bypass capacitor (100 µF) across the 5 V terminals too.

Tomwhite1124:
I’ll try and wire up a matrix of LEDs in the 8x8 confg then extend from that to the lighting on my system I’m unsure if all 8x8 is required for the matrix to work

OK, the matrix will work perfectly well with any number of LEDs not present, it will not affect the operation or brightness in any way. However, the matrix is strobed by cathode drivers corresponding to the "digits" and you can initialise the chip for any number from 1 (ridiculous) to eight, so if you needed only 40 LEDs, you could use only five columns or "digits" in the array and rather than spending one eighth of the time on each "digit" it will spend one-fifth of the time on each, they will be that much brighter (but the brightness of all LEDs on at the one time is actually programattically controllable in sixteen steps).

So you can most certainly test - and use - it with fewer LEDs.

Tomwhite1124:
From what information I’ve seen with it though the delay between changing the character or text on the matrix is a delay
function can this delay be changed to a timer of some sort in the code

No delay is required with the MAX7219. There are two ways to connect and program it with the Arduino, the "SPI" is extremely fast. Because it provides the matrix scanning for you, you only ever send it new data when you want to change the visible pattern. The rest of the time you ignore it completely.

Tomwhite1124:
also if using a mosfet to control the led lighting strip 12v and using a PWM signal to control the brightness can this also be included into the code on the same board so it all works as one as such

That as they say, is what a microcontroller (microprocessor) is for. It performs things literally within the blink of an eye. You actually have to program it to do anything "slowly" but it provides a timer function, "millis()" for you in the IDE to wait for the right time for things to happen. But you never "busy wait" for anything, in the loop() you repeatedly check in turn for a whole series of events such as button presses or times to occur, only acting on any particular event when it has actually been detected.

And the PWM is generated for you by internal timers in the Arduino - you merely specify what duty cycle you want, and it is generated continuously until you tell it otherwise - like the MAX7219.

Paul__B:
OK, so you essentially have "bare" LEDs for the street lights and will be using plain LEDs for the buildings. Perfect!

So, a MAX7219 module will control up to sixty-four of them wired in a matrix, operating from 5 V and you do not need resistors as the MAX7219 controls the current for you. It will control, each LED individually but the brightness of all (which are switched on at any one time) together.

Sixty-four would probably cover all of your LEDs, but in case it did not, these are chain-able - you can use two, three, four, eight in a row, connected from the same control pins on the Arduino. Actually, if you use significantly fewer LEDs, you do not need all eight columns of the matrix and the LEDs will be a little brighter when you program the chip accordingly.

Here is a diagram of the internal connections of that LED matrix itself, to indicate how you would wire your LEDs to correspond:

Please do not buy an Arduino UNO - they are not suitable for construction projects such as this. :astonished: You want a "Nano" which comes with connection pins supplied, but for this, you would instead solder wires directly to the terminals.

Click for eBay supplier.

Here is a MAX7219 matrix module:

Click for eBay supplier.

It comes with an 8 by 8 LED matrix because the intended purpose is to generate patterns, but because you do not want that but rather to use your own matrix of LEDs, you just use the module to implement your own wiring; the MAX7219 is already mounted.

All this part will be powered at 5 V. The Arduino board cannot regulate 12 V to 5 V for you, you either use a regulated 5 V supply such as a "phone charger", or a step-down "buck" regulator (cheaply available on eBay) from your 12-16V supply.

I leave you to the other comments regarding strip lighting, but the controllable LEDs are easy!

What about dimming leds? With different colors like RGB leds?

If you want colours, you use "NeoPixels".

We seem to be working on the same thing! Awesome. Please check out this page for my work so far. I'm using a Teensy microcontroller which uses Arduino for programming as well as a Raspberry Pi. There a tonne of cool stuff you can do with your layout. Check out my project logs for some arduino/led programming - Not Just Another Coffee Table | Hackaday.io