All Forums > Electronics Questions

Controlling 400 LED

(1/1)

dmm002:
Hi all,

I'm working on a personal project and I want to control almost 400 LED's separately one from each other.

Any suggestions?

I think I might use some sort of chip that allows to control at least 15 LED's with one Wiring pin, but I have no idea which chip should I use...

Thank you very much!

Qynx:
The PCA9685 from NXP

16 led for 1 chip. 400/16= 25 chips works with I2C.



Rob

Qynx:
For your (extra) information Simple code for a turning random on/off 16 leds (1x PCA) in a random level 0....4096 steps.



--- Code: ---
#include <Wire.h>

#define PCA9685      0x40 // I2C address for PCA9865 with all inputs at zero
       
    void setup() {

      Wire.begin(); // initaliseer I2C

      Wire.beginTransmission(PCA9685);
        Wire.write(00);     //MODE1 register
        Wire.write(0x01);   // reset the device
      Wire.endTransmission();

      Wire.beginTransmission(PCA9685);
        Wire.write(00);
        Wire.write(0xa1);  // 0xa1 // Restart enabled, Register Auto Increment and PCA9685 responds to LED ALL Call I2C-bus address.
       Wire.endTransmission();

      Wire.beginTransmission(PCA9685);
        Wire.write(01);    // MODE2 register
        Wire.write(0x10);  // Output logic state inverted. Value to use when no external driver used.
      Wire.endTransmission();
    }

    void loop()  {

     #define vertraging 10     

     Set_duty_cycle(random(16),random(4096));   
     delay(vertraging);
     Set_duty_cycle(random(16),0);   
     delay(vertraging);

    }

  void Set_duty_cycle(unsigned char DeLed,unsigned int Level)  {
    Wire.beginTransmission(PCA9685);
      Wire.write(0x06+(4*DeLed)); //LED register starts at register 0x06
      if(Level>=4096)  {
        Wire.write(0x00);                  // set to output start lsb
        Wire.write(0x10);                  // set to output start lmsb
        Wire.write(0x00);                  // set to output end lsb
        Wire.write(0x00);                  // set to output end msb
      } 
      else  {
        Wire.write(0x00);                  // set to output start lsb
        Wire.write(0x00);                  // set to output start lmsb
        Wire.write((char)(Level&0xff));    // set to output end lsb
        Wire.write((char)(Level>>8&0xff)); // set to output end msb
      }
    Wire.endTransmission();
  }


--- End code ---


Rob Keij

dmm002:
Thanks! I'll try that =)

Sibiler:
I couldnt stop here am tell u guys my oppinion, i love when on forums are nice and helpfull people like here, great community!!

Navigation

[0] Message Index

Go to full version