Arduino Attiny85 Charlieplexing

by manu4371 in Circuits > Arduino

22004 Views, 124 Favorites, 0 Comments

Arduino Attiny85 Charlieplexing

IMG_5603.JPG

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.

A Bit of Theory

polygone.jpg
20leds5pins.gif
truthpolygon5.jpg

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.

The Schematic

CHARLYPLEX5.jpg
IMG_5604.JPG
IMG_5607.JPG

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

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

Presse-papiers-1.jpg
8190539835_43645be236_m.jpg
8190511795_2c2772bce4.jpg
8506891223_4a877dc5d3.jpg
Presse-papiers-2.jpg

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

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);

Conclusion

Thanx for all interesting and working tutorials on the net.