Author Topic: Controlling 400 LED  (Read 2775 times)

0 Members and 1 Guest are viewing this topic.

dmm002

Controlling 400 LED
« on: November 05, 2012, 12:30:10 PM »
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

Re: Controlling 400 LED
« Reply #1 on: November 10, 2012, 06:39:40 PM »
The PCA9685 from NXP

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



Rob

Qynx

Re: Controlling 400 LED
« Reply #2 on: November 12, 2012, 02:48:31 PM »
For your (extra) information Simple code for a turning random on/off 16 leds (1x PCA) in a random level 0....4096 steps.


Code: [Select]

#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();
  }



Rob Keij

dmm002

Re: Controlling 400 LED
« Reply #3 on: November 13, 2012, 04:50:42 AM »
Thanks! I'll try that =)

Sibiler

Re: Controlling 400 LED
« Reply #4 on: November 15, 2017, 04:52:50 AM »
I couldnt stop here am tell u guys my oppinion, i love when on forums are nice and helpfull people like here, great community!