This was one of those projects were I had a good idea in hand, but by the end it turned out quite different; and I am quite pleased how it turned out.
I wanted to make my Wife something nice this year for putting up with my various projects. Those on the "list," those in planning, those in progress, those finished, and some abandon.
My original idea was to cut a heart out of wood, mount the 8x8 matrix in a hole in the middle, and mount the ATtiny on a PCB somewhere. I couldn't make up my mind in front or back. While those ideas where being pondering and experimented with, I started on the hard part of the project.
I looked in my stock as I had both the ATtiny85 and 8x8 matrix handy. Wow, that seemed like a first, I didn't have to order anything. I hadn't really used the matrix before so I downloaded the Adafruit libraries and hooked it up to my Uno clone and started to play around. I used both the Adafruit_LEDbackpack and Adafruit_GFX. The animations are pretty straight forward. You have to create your image with 0 & 1's, then call each of them as you need them.
CodeHere is an example from my code that shows part of the heart being drawn, it is the center square.
heart2_bmp[] =
{ B00000000,
B00000000,
B00000000,
B00011000,
B00011000,
B00000000,
B00000000,
B00000000, },
Text scrolling is straightforward, but for those who are new, lets pick it apart a little bit and see what is going on.
matrix.setTextWrap(false);
matrix.clear();
for (int8_t x=8; x>=-100; x--){
matrix.clear();
matrix.setCursor(x - 8, 0);
matrix.print("1 short text");
matrix.writeDisplay();
delay(100);
To start, the text shouldn't wrap as a message will be scrolling across the matrix. The first variable, x=8 is where the text will start to scroll across. This example starts on the right and moves towards the left. x>=-100 is allowing room for the characters. I took the total number of characters in my text message and multiple it by 9 and the text displayed correctly. If you miscalculate you might not see the whole message. This happened to me as the original message was about 4 characters and the value was 96. My message was much longer, but I hadn't changed the 96. Once it was bumped higher all worked out well.
I was using my Uno clone to do the testing. It is just much quicker to make a change and upload it quickly. Everything was moving along great, but I noticed one thing, the message wasn't oriented right, it was a bit upside down.
There is another command that comes in useful.
matrix.setRotation(1);
With it you can rotate the screen in any of the four directions depending on where you need/want the pins to orient. Setting it to one put 0,0 in the upper, left-hand corner, with the pins pointing downward. Or as in one part of my code I use the rotation to spin the heart.
ProgrammingNow is was time to program the ATtiny. I do like working with these little guys. They work quite well in a lot of my projects and can take up a lot less space than an Uno. There are some great guides out on the net on programming the ATtiny family of processors. The only hiccup I had was dealing with the Wire library.
While libraries might be compatible within the ATMel family of chips, there is the space consideration. And the ATtiny85 doesn't have the room of its big brother. There is a Wire library that was made just for the ATtinys, it is also from Adafruit. WireTinyM. Once I updated that it worked much better. I left in both for when making changes and updates. Depending on which one I am using I can just comment out the other.
During all of this I am still pondering how to make the mount for all of my little bits. I start to look at the 8x8 and the Tiny and figure what the hay. There are only 4 pins that need hooked up. And this would probably look way cooler than protoboard as there is no time to get a PCB fabricated and delivered. It seemed to so simple, 4 pins to 4 pins. It took a couple of tries in trying to find what might look best and also work the best.
Well, it struck me. It had earlier, but wasn't too hip on the idea at first and then it just started to grow on me the more I thought about it. I got myself a length of electrical wiring. I had a length of 3-wire left over from a kitchen project. I pulled out the ground wire and bent it in the shape of a heart. I would then just be able to hang the matrix and Tiny from the top of it. Shazaam!
After that it was a matter of finding a base (a birch log part that was from a wedding center piece and some Lake Superior lake shore rocks).
Finishing touchesOh last but not least, I had to power it. I was going to use USB cable, but no, that would be just too much hassle. AA?? Naw, too many and won't last too long. Hey, I have one of those lipos at 3.7, I wonder if it would work? I know the ATTiny will work at 3.3V and that data sheet states the lowest power the for the matrix is 2.7. What the heck. I wired up a JST battery connector and plugged it it - DONE!
Comments
Please log in or sign up to comment.