Arduino Attiny85 Charlieplexing

11,733

96

5

Published

Introduction: Arduino Attiny85 Charlieplexing

It's rainning leds...

Last week I saw in a shop a curious thing: a small microcontroller like Attiny85 (8 pins) controlling 20 leds with a rain effect!!

An impossible thing working with the famous Charlieplexing algorithm.

Step 1: A Bit of Theory

The schematic of the raining leds is based on geometric figures: the polygons. Each vertices are controlled by one digital pin of a microcontroller and the edges are made of LED mounted paralell and inverted. So for 5 pins, you control 5 vertices and 10 edges of 2 leds each: 20 leds. A wiki article deals with the polygons:

http://en.wikipedia.org/wiki/Complete_graph

To control each LED you have to polarize the LED you want to light on (+ on a vertice anode and - on the vertice kathod) and apply high impedance on the other vertices.

I use an attiny 85 programmed with the arduino sketch. So it uses 5 pins for 20 leds. If you want more: 6 pins for 30 leds, 7 pins for 42 leds, 8 for 56 leds...use an atmega328p/644p/1284p.

So each led, one by one (D1 to D20) are switched on and the fade off every four leds to give a rain effect with a random cycle. You can see it in the truth table i tried to make.

Step 2: The Schematic

5 pins are used for the 5 vertices, 2 pins for the power supply and 1 pin for the Charlie plexing algorithm. Respect the number of the led to make the circuit (D1 to D20).

Step 3: Programming the Attiny85 (8MHz Internal Clock): Burn the Bootloader

You need first to upload the sketch arduino in this microcontroller.

1- connect arduino uno to your PC

2- launch arduino UNO

3- select the good com port

4- file/example/arduino as ISP

>> https://github.com/damellis/attiny/tree/Arduino1

- In your Arduino sketchbook folder create a new sub-folder called “hardware”

- Put the “ATtiny” folder inside this “hardware” folder

- You should end up with folder structure like this: “Documents > Arduino > hardware > attiny”

- Quit and restart the Arduino software
- Look inside the “Tools > board” menu and you should see the ATtiny entries

ATtiny —– Arduino

Pin PB2 (SCK) —– Pin 13

Pin PB1 (MISO) —– Pin 12

Pin PB0 (MOSI) —– Pin 11

Pin PB5 (Reset) —– Pin 10

Plus (VCC) —– +5V

Minus (GND) —– GND

10uF Capcitor: not necessary

Arduino pins: RESET —-||—- GND

- Select “ATtiny85 (8 MHz internal clock)” from the “Tools > Board” menu

- Select “Arduino as ISP“ from the “Tools > Programmer” menu

9- if this message is displayed your Attiny85 can be programmed now with aduino sketch.

Here, a good website:

http://www.kobakant.at/DIY/?p=3742

Step 4: The Charlieplexing Program

The Charlieplexing program is here:

https://github.com/strykeroz/ATTiny85-20-LED-snowf...

You've got all you need to work your 20 leds rain effect!!!

It's rainning leds!!!

In the program:

- HIGH state with: pinMode(pin,INPUT); digitalWrite(pin, HIGH);

- LOW state with: pinMode(pin,INPUT); digitalWrite(pin, LOW);

- high impedance Z state with: pinMode(pin,OUTPUT);

Step 5: Conclusion

Thanx for all interesting and working tutorials on the net.

Recommendations

• Arduino Class

70,492 Enrolled

5 Discussions

LOL! I just went through all the theory and built my 9-Charlieplexor and wrote up my Instructable. Then right there on the right side of the page after I posted was this Instructable. You even showed graph theory too. I wish I had found this a month ago! I plan to use the attiny85 or similar myself and will likely use your code. Well done.

2 replies

I hope it will be usefull for your new project. You do have spent a lot of time to do your 9 charlieplexor. It 's very complicated to link every LED: you need to focus on your schematic all the time to repect the good colors of your wires. May be you can control up to 30 LEDS with an attiny 85, I haven't tested it yet.

Merry Xmas and happy new year.

It is! And I've 'discovered' ribbon cables. Now it's going pretty fast.

I really like the "star" notation for visualizing the Charlieplexed schematic!

I have an interrupt-driven version of the firmware at https://github.com/rmd6502/charlie_heart