My Valentine’s Dead Bug

*** This was a quick copy and paste. I will be back to edit it soon!

 

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 8×8 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 8×8 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. 

Here is an example from my code that shows part of the heart being drawn, it is the center square.

<span style="box-sizing: border-box;"> heart2_bmp[] = </span><span style="box-sizing: border-box;"> { </span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00000000, </span></span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00000000, </span></span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00000000, </span></span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00011000, </span></span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00011000, </span></span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00000000, </span></span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00000000, </span></span>
<span style="box-sizing: border-box; margin-bottom: 0px;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">B00000000, </span>}, </span>

Text scrolling is straightforward, but for those who are new, lets pick it apart a little bit and see what is going on.

<span style="box-sizing: border-box;"> <span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">matrix</span>.setTextWrap(false); </span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">matrix</span>.<span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">clear</span>(); </span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">for</span> (int8_t x=<span class="hljs-number" style="box-sizing: border-box; color: #ae81ff;">8</span>; x>=<span class="hljs-number" style="box-sizing: border-box; color: #ae81ff; margin-bottom: 0px;">-100</span>; x--){ </span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">matrix</span>.<span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">clear</span>(); </span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">matrix</span>.setCursor(x - <span class="hljs-number" style="box-sizing: border-box; color: #ae81ff;">8</span>, <span class="hljs-number" style="box-sizing: border-box; color: #ae81ff; margin-bottom: 0px;">0</span>); </span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">matrix</span>.<span class="hljs-keyword" style="box-sizing: border-box; color: #f92672;">print</span>(<span class="hljs-string" style="box-sizing: border-box; color: #e6db74; margin-bottom: 0px;">"1 short text"</span>); </span>
<span style="box-sizing: border-box;"><span class="hljs-keyword" style="box-sizing: border-box; color: #f92672; margin-bottom: 0px;">matrix</span>.writeDisplay(); </span><span style="box-sizing: border-box; margin-bottom: 0px;"> delay(<span class="hljs-number" style="box-sizing: border-box; color: #ae81ff; margin-bottom: 0px;">100</span>); </span>

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(<span class="hljs-number" style="box-sizing: border-box; color: #ae81ff;">1</span>)<span class="hljs-comment" style="box-sizing: border-box; color: #75715e; margin-bottom: 0px;">;</span> 

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.

Now 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 8×8 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).

Oh 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!

SCHEMATICS 

Img 1853 3hpmbc0wrk

Side Project – MacPi Plus

Raspberry Pi Model 3 into a Mac Plus case 

My Raspberry Pi has been sitting on my bench in a little plastic box. It seems so naked and bare; it needed something to spice things up. And I needed another project on my list, like I am not sure what, but it has ended up on my list.

I have had an old Mac Plus case laying around for years. It has served as a desktop bookcase to recently a collecting bin for cables. The face plate was made into a cheesy, but geeky picture frame. It took some time to clean it up a bit. I didn’t go through all of the trouble to really scrub it down. I like a little of the aged, plastic, patina, look to it, but it does look scads better than it did.

My first goal for this project is to see how much I can use that I have laying around. I have rounded up most of the parts I need.

  • Mac Plus Case
  • Raspberry Pi – bought
  • SainSmart 7″ TFT LCD – bought
  • USB hub, powered
  • SD card slot extender
  • Ethernet cable extender

I am sure I will need some more bits and parts as time wears on, but for now this will get me started.

While working on getting the screen working with the Pi (what a pain, but this will be another post later) I have been laying to how to put things together. The first order of business was the screen. I was trying to find a 4:3 aspect monitor, but didn’t like what I found. I started looking at the Raspberry Pi “compatible” screens. I originally wanted to get the larger 8″ screen, but after measuring a couple of times, I was sure it wouldn’t fit. So I decided on the 7″ screen.

I need a way to mount the screen to the inside of the face plate. What to use? It took me a day or so of rummaging around to find something that seemed appropriate to use. Somewhere in my travels I had a rather large pass-through card, but the right size for holding the screen and with a little Dremel work on the connectors it fits in the face plate.

I took a piece of cardboard and traced the outline of the screen opening on the faceplate. I then added another piece of paper representing the screen to help figure out the placement of it and the screws.

I have to drill the holes in the plate to attach it to the face plate as well as 4 more holes to mount the screen.

 

Well, that is it for now. Check back as I will be updating as I keeping plugging along on this one. Like I said it is a side-project. While not pretty, the bare Pi and VNC work fairly well for the work it currently does, but it deserves a nice Macinficantion.