Valentines Day

You are currently browsing articles tagged Valentines Day.

Every year, I make Sheena a Valentines card. A few years ago I didn’t have a chance to go to the local card shop, and made one from art supplies I had on hand. Now I’m doomed — I can’t go back to buying cards.

This year I decided to raise my game a little, or at least incorporate another hobby. As I mentioned earlier, this is a blinky sign. It has an 8×8 LED matrix and an Atmel ATmega48 on board, as well as a CR2032 watch battery. The ATmega uses its internal oscillator, so there is very little supporting circuitry. It doesn’t sound exciting on it’s own, but context is everything.

Valentines Card

The local art store had cards and envelopes in different sizes. I picked a much larger envelope as the assembled card is rather thick. The hearts are cut from red craft foam, and hot glued on to the card and envelope.

Valentines Card

The circuit board is bolted to an acrylic backplate. The card and a black piece of craft foam are sandwiched in place. This will hopefully prevent the circuit board from tearing through the card.

Valentines Card

The software has about 25 different messages, and it steps through them each time the button is pressed. Then it puts itself into power down mode until the next button press. Updating the matrix is handled by an interrupt routine that reads from a circular buffer. There’s also a putchar routine that feeds into the buffer, so I can use it with I/O streams. This lets me use printf to write to the matrix.

And the font: The only 8-bit font with a heart character I know of is the Commodore 64 system font. I created ROM dumps from a C-64 quite some time ago, including the character generator. The C-64 was a strange machine by modern standards. Not only did the internal character representation differ from ASCII — the Commodore version was called PETSCII — but the font in the character generation and the stored screen state both used yet another representation known as screen code. I’ve modified the font into something more like ASCII, with the heart character as 0x7f. Please don’t hurt me, Commodore!

The final code, with the font in program memory, comes to 4004 bytes, just fitting inside the 4096 bytes available. The font takes up 768 bytes of flash, and the avr-libc printf implementation takes up another 1.5k or so.

There are more pictures in this flickr gallery.

The code is posted on GitHub.

Lessons Learned

  • AVR microcontrollers have some mad power management capabilities. While running, this card consumes around 20 millamps. While sleeping, it consumes ~1 microamp.
  • When wiring up an LED matrix, think about which end should be the most significant bit. I wired up this project to be little-endian (MSB at the right), while the font I used was big-endian (MSB at the left). This was easy enough to fix in software.
  • Additionally, I’m reaching the point where point-to-point prototyping may no longer be feasible. I guess I have to break down and learn some real circuit layout software.
  • I should probably plan ahead more — It’ll be tough to top this next year.

Tags: , , , , ,