Date | 2016-04 |
---|---|
Tool Version | Arduino IDE 1.6.5 (Windows) (arduino.avrdude=6.0.1-arduino5, arduino.avr-gcc=4.8.1-arduino5) |
Keywords | LED, WS2812, Arduino Uno, ATmega328, ATtiny45 |
This program displays animations on one, two or four 8x8 LED WS2812 matrices. You can switch between the animations by pressing a button.
There are two versions, one for the Arduino Uno rev3 running at 16MHz and one for an ATtiny45 running at 20MHz.
ATmega328P (Arduino Uno rev3) | ATtiny45 | |
---|---|---|
Clock | external 16MHz | external 20MHz |
Voltage | 5V | 5V |
Current | < 2A |
The layout of the LED matrices is defined in ledMatrix.h:
- #define MATRIX_8x8
One 8x8 LED matrix - #define MATRIX_2X8x8
Two 8x8 LED matrices, giving 16x8 LEDs; left: LEDs 0 to 63, right: LEDs 64 to 127 - #define MATRIX_2x2X8x8
Four 8x8 LED matrices, giving 16x16 LEDs; top: LEDs 0 to 127, bottom: LEDs 128 to 255
If you use a different layout (e.g. 3x1) you have to add a new #define. In ledMatrix.h you have to add some constants for the new layout and in ledMatrix.cpp you have the add the conversion calculation from x/y coordinates to LED index and vice versa.
If you want to add an animation, you have to implement an initialization function and a run function. Then you have to add the function calls to the led-8x8.asm file. Please consider that the RAM of the ATtiny45 is too small for a memory mapped display and calculating the each pixel color must be done within 50us because of the WS2812 protocol. However you can use an ATtiny85 with more memory or an ATmega328P where memory is not an issue at all.
If you don't want to compile yourself, upload the included hex file (using one 8x8 matrix) with avrdude.
- If you don't have a 'make' get and install it (http://gnuwin32.sourceforge.net/packages/make.htm)
- Open command line box, change directory to the source folder of this project
- Check the settings at the top of the 'Makefile'
- ATmega328P: Run 'make MCU=atmega328p' to create the hex file
- ATtiny45: Run 'make MCU=attiny45' to create the hex file
- Run 'make MCU=atmega328p Upload' to upload the hex file
- Connect Arduino's 5V, GND and Digital Pin 8 to the LED matrix' 5V, GND and DIN pins, connect Arduino's GND and Digital Pin 2 with a push button as shown in the image
- To upload the hex file to the ATtiny45 with an Arduino Uno board as programmer follow the instructions on http://highlowtech.org/?p=1695 'connecting an Arduino (as ISP) to an ATtiny'
- Run 'make MCU=attiny45 Upload' to upload the hex file
- Run 'make MCU=attiny45 Fuses' to make the ATtiny45 use an external clock source. Warning: After burning the Fuse you cannot use the ATtiny45 without an external clock (not even reprogram to clear the fuse)!
- Setup the ATtiny45, 20MHz oscillator, two 22pF capacitors, 10uF capacitor, push button and the LED matrix as shown in the image
- http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf
- http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf
- http://www.atmel.com/Images/Atmel-0856-AVR-Instruction-Set-Manual.pdf