The LED Matrix lives! This weekend I got it put together and blinking it’s blinkies!
More details after the cut.
This project was my first time soldering surface mount components. The great SMD How To Tutorial from Sparkfun to guided me through this process. I did not use any specialized equipment. My cruddy Radio Shack soldering pencil, some flux cored solder, a little desoldering braid, a tiny pair of tweezers, my reading glasses, and a good light were perfectly adequate. Next time I’m going to get some liquid flux. I think that would make things flow together a bit easier.
At first I only soldered the ATTiny, the 17th LED, and the programming header to verify operation before tackling the rest of the LED field. The following command will verify the checksum of the ATTiny using the usbtiny Atmel programmer I assembled last week.
/opt/local/bin/avrdude -c usbtiny -p t25 -v
After sucessfully verifying the checksum, I moved on to making LED 17 blink. I adapted Paul Grayson’s Linux Atmel AVR Tutorial for use with my Mac, programmer, board, and application. I would recommend anyone who is interested in learning avr-gcc do the same.
My program simply sets pins 3 and 4 of my ATTiny25 as outputs and then blinks the LED on and off at a 5% duty cycle.
// blink17.c #define F_CPU 10000000UL #include <avr/io.h> #include <util/delay.h> void delayms(uint16_t millis) { //uint16_t loop; while ( millis ) { _delay_ms(1); millis--; } } int main(void) { DDRB |= 1<<PB3; DDRB |= 1<<PB4; while(1) { // LED off - both low PORTB &= (1<<PB3); PORTB &= (1<<PB4); delayms(1); // LED on - PB3 high PB4 low. PORTB |= (1<<PB3); PORTB &= ~(1<<PB4); delayms(1*20); } return 0; }
The following Makefile will compile and program the device. I had already installed avr-gcc on my mac using mac ports. If you are attempting to use these instructions yourself you will have to update CC and OBJ2HEX to match the paths on your system.
CC=/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-gcc CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=attiny25 -I/usr/local/avr/include/ OBJ2HEX=/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avr-objcopy TARGET=blink17 all : $(TARGET).hex %.obj : %.o $(CC) $(CFLAGS) $< -o $@ %.hex : %.obj $(OBJ2HEX) -R .eeprom -O ihex $< $@ program : $(TARGET).hex /opt/local/bin/avrdude -c usbtiny -p t25 -U flash:w:$(TARGET).hex clean : rm -f *.hex *.obj *.o
Next up, scrolling text!