# Arduino Attiny85 Charlieplexing

15,514

108

6

## 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.

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## 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

5- download it to arduino uno

6- Download the “ATtiny” folder from this GitHub repository:
>> 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

7- Wiring your ISP connection
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

8- Burn Bootloader:

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

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

- Select “Burn Bootloader” from the “Tools” 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

You need to download the library entropy.h supplied here.

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,OUTPUT); digitalWrite(pin, HIGH);

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

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

## Step 5: Conclusion

Thanx for all interesting and working tutorials on the net.

73
245 17K
112 24K

## 6 Discussions

Made this with help of a 3D printed housing and a power supply fabricated from a 7805 Voltage regulator and a recycled smoke detector 9V battery.

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.

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

Hello and happy new year!

Thanx for your support and I give you the link where I found the animated gif example:

http://www.postcogito.org/Kiko/BcdClock.html#The_B...

Your version is very interesting and a litle bit more complicated than mine. I think I will test the code to create in the furture a matrix LED display (I use as I can recycled LEDS).

Best regards. Manu.

ps: one day I will see NY.