Charlieplexing a row of LED's

I mainly fool with motors and such but my 13 year old daughter wants to put some blinking led's on a project. It's going to be about 40 leds in 4 groups of 6-10. She wants a random pattern between groups. I'm going to be very busy with work this week so it's going to have to be done over the weekend.

Any tips? I need to know if any parts will be required so I can order soon.

Thanks.

Wow, I really hate to bump my own thread but if anyone has any parts recommendations I need to get them on the way...

Her project is a sort of animated atom with 12 neutrons and 12 protons in the nucleus. She was thinking two different colors and having them blink in a pattern. The first shell will have 8 leds and only 2 will be illuminated at once, also in a blinking pattern. The 2nd shell will have 12 leds with 8 illuminated at once in a pattern similar to the 1st and the 3rd shell will have 8 leds with 2 illuminated. I hope that makes sense. I don't really have time to do a lot of searching so I was hoping for some help.

I ordered abut 200 leds from ebay a while back and my daughter thought the project up and has already built some of the "hardware" :blush:

She's pretty good at soldering because she makes jewelry from old computer board parts :slight_smile: so she'll handle most of the work. It just came at a bad time because this week is REALLY busy at work so I don't have much free time. I need to get in the bed soon...

Anyway, I have a couple of 328 chips that aren't doing anything and I have experimented a little bit with multiplexing on attiny 85's but that's about it.

Any help would be GREATLY APPRECIATED!

Thanks.

I ordered a couple of MAX7219CNG chips. I guess I'll study up on them this weekend...
Any tips?

Strange things going on here. I feel sure I replied to you suggesting the MAX7219 might be a suitable chip and giving links etc but I see no reference to the post. Am I imagining things?

I'm confused...

I was going by this: http://www.instructables.com/id/CharliePlexed-LED-string-for-the-Arduino/

And I basically copied it only I added an ATtiny 85 to it instead of using an Arduino.

At least it's doing something...

hoff70:
I was going by this: http://www.instructables.com/id/CharliePlexed-LED-string-for-the-Arduino/
And I basically copied it only I added an ATtiny 85 to it instead of using an Arduino.
Cannot help you with ATtiny85 as I don't use them but it might be a hard job driving 40+ LED's with one.

http://www.youtube.com/watch?v=SgrLfPds3n0&feature=youtu.be
Look like EMI are being a bit over zealous if this is your own video & audio

This video contains content from EMI, who has blocked it in your country on copyright grounds.
Sorry about that.

Sorry about the vid. I guess I need to stop putting music to them.

I built this:

The pins at the bottom are numbered in the order they connect to the 85. I'm just trying to get something working with 12 leds for now.

I found some code that compiled and loaded fine but damned if I can get it to work properly...

the matrix is like this (led ground is the first number):

Led1-2,3
Led2-1,3
Led3-0,3
Led4-0,2
Led5-1,2
Led6-3,2
Led7-2,1
Led8-0,1
Led9-3,1
Led10-2,1
Led11-1,0
Led12-3,0

This is the sketch I'm playing with:

#include <avr/pgmspace.h>  //This is in the Arduino library

int pins[4];
int blinkdelay = 200;   //This basically controls brightness. Lower is dimmer
int runspeed = 150;      //smaller = faster

const int ledPins[12][2] ={ // This stores the led pins order NOTE:You may need to change the order of these
  {
    3,2  } //1
  , 
  {
    3,1  }//2
  ,
  {
    3,0  }//3
  ,
  {
    2,0  }//4
  ,
  {
    2,1  }//5
  ,
  {
    2,3  }//6
  ,
  {
    1,2  }//7
  ,
  {
    1,0  }//8
    
  ,
  {
    1,3  }//9
  , 
  {
    1,2  }//10
  ,
  {
    0,1  }//11
  ,
  {
    0,3  }//12
  ,


};

byte displays[][12] PROGMEM ={  // This stores the array in Flash ROM. You can easily have 500+ frames.
  //left right blinking
   {0,1,1,1,0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0,1,1,1,0},
   // out in blinking
   {0,0,0,0,0,1,1,0,0,0,0,0},
   {1,1,0,0,0,0,0,0,0,0,1,1},
   // counting in binary
   {0,0,0,0,0,0,0,0,0,0,0,0},
   {0,0,0,0,0,0,0,0,0,0,0,1},
   {0,0,0,0,0,0,0,0,0,0,1,0},
   {0,0,0,0,0,0,0,0,0,0,1,1},
   {0,0,0,0,0,0,0,0,0,1,0,0},
   {0,0,0,0,0,0,0,0,0,1,0,1},
   {0,0,0,0,0,0,0,0,0,1,1,0},
   {0,0,0,0,0,0,0,0,0,1,1,1},
   {0,0,0,0,0,0,0,0,1,0,0,0},
   {0,0,0,0,0,0,0,0,1,0,1,0}
};


// The setup() method runs once, when the sketch starts

void setup()   {                
  // initialize the digital pin as an output:
  pins[0] = 0;
  pins[1] = 1;
  pins[2] = 2;
  pins[3] = 3;
  sequenceon(); // Does one loop of the cylon effect
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                     
{
    sequenceon(); //Turns on cylon effect
//  displayChar(0,1, 100); //In/out blinking
//  displayChar(4,14, 200); //Counts to 15 in binary
}

void displayChar(int from, int through, int tranSpeed)// loads a Pattern from above. From & though spesify what patterns to show. tranSpeed is the speed of the frames
{
  boolean run = true;
  byte k;
  int t = from;
  while(run == true)
  {
    for(int i = 0; i < tranSpeed; i++)
    {
      for(int j = 0; j < 12; j++)
      {
        k = pgm_read_byte(&(displays[t][j]));
        if (k == 2)
        {
          run = false;
        }
        else if(k == 1)
        {
          turnon(j);
          delayMicroseconds(blinkdelay);
          alloff();
        }
        else if(k == 0)
        {
          delayMicroseconds(blinkdelay);
        }
      }
    }
    if(through == t){
      return;
    }
    t++;
  }
}
void ledSpecify(int highPin, int lowPin) // This allows you to manually control which pin goes low & which one goes high
{
  for(int i; i < 4; i++){
    pinMode(pins[i], INPUT);
  }
  pinMode(pins[highPin], OUTPUT); 
  digitalWrite(pins[highPin], HIGH);
  pinMode(pins[lowPin], OUTPUT); 
  digitalWrite(pins[lowPin], LOW); 
}

void turnon(int led) // This turns on a certian led from the list of leds
{
  int pospin = ledPins[led][0] + 2;
  int negpin = ledPins[led][1] + 2;
  pinMode (pospin, OUTPUT);
  digitalWrite (pospin, HIGH);
  pinMode (negpin, OUTPUT);
  digitalWrite (negpin, LOW);
}


void alloff() // This turns all the LED's off
{
  for(int i = 0; i < 5; i++)
  {
    pinMode (pins[i], INPUT);
  }
}

void sequenceon() // This handles the cylon effect
{
  for(int i = 0; i < 12; i++)
  {
    turnon(i);
    delay(100);   
    alloff(); 
  }
  for(int n = 10; n > 0; n--)
  {
    turnon(n);
    delay(100);   
    alloff();   
  }
}

Ye Olde Charlieplex schematic:

I just noticed that the 85 only has 3 analog inputs and I'm only using 1. Not sure if that's part of the problem...

I figured I'd change the thread title because this is what It's morphed into.

New matrix schematic:

In the code where the pins are listed in order does the cathode or anode go first?

In the code where the pins are listed in order does the cathode or anode go first?

Looking at the below code snippet it seems the first entry is the anode and the second the cathode. I'm not sure why it has the + 2 on the end though as it seems to be upping the pin numbers and according to this http://hlt.media.mit.edu/?p=1695 the 85 only has 5 usable pins (0-4 under this core) so '3,2 } //1' would equate to 5,4?

void turnon(int led) // This turns on a certian led from the list of leds
{
  int pospin = ledPins[led][0] + 2;
  int negpin = ledPins[led][1] + 2;
  pinMode (pospin, OUTPUT);
  digitalWrite (pospin, HIGH);
  pinMode (negpin, OUTPUT);
  digitalWrite (negpin, LOW);
}

I'm just kind of curious why you're using charlieplexing for your original goal. If you have 4 groups of 6-10 LEDs, why not control each group off an I/O pin with a transistor to provide enough current? This will make your code trivial and charlieplexing 40 LEDs means you have a 2.5% duty cycle so may have a brightness issue.

Even if you want to control each LED individually, 40 LEDs only takes 13 IO lines for a normal matrix configuration (vs 7 to charlieplex) and you benefit from simpler code and better duty cycle. If you're that short on IO (which doesn't appear to be the case here), you can use a decoder or shift register to reduce your IO pin count.

Why don't you just multiplex them? 40 LEDs would require 5*8 = 13 pins. This would be much easier to implement.

I have a charlie-plexing FAQ at http://wiblocks.luciani.org/FAQ/faq-charlie-plex.html

I also make an 8x8 and 10x10 and circular board that uses charlie-plexing. The schematics
are in the datasheets. The information on the 8x8 board is at Loading...

Information on the software is at Loading...

You may be able to adapt the schematics and software to work for your project.

(* jcl *)

http://www.wiblocks.com