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

Doh!

This was meant to be a one-off, lets just have some fun kind of project. I was once told if you don’t learn something new everyday it just wasn’t a day. And I did learn in my eagerness for some quick video gaming gratification. 

I had been trolling through my parts box and thinking of a fun project to work on. Then I remembered two things. First was the ATTiny85 video games. I always have ATTinys laying around so this would be great. I checked the BOM and I had everything save the PCB boards and they are available on OSHPark. I even had a spare OLED screen in my display box. COOL. And, and, a way back I had an online bump in with Drew of OSHPark and he had sent me a gift certificate for boards. Excellent. I quickly put in my order and it was under $4.00 so still plenty left on the coupon to get my first PCB designed board done. 

I placed the order and forgot about it for a while. After all of the slow boat from China orders I tend to forget about things once I order them, I can’t stand being obsessive over something that is just going to take its time. Anyhow, low and behold one day when I get home from work there is a little package from OSHPark. I quickly get into it and see the 3 pretty purple boards and my OSHPark sticker for the collection, just waiting for a quick trim with the Dremmel and then get populated. 

IMG 0922

When I wasn’t waiting for the boards I took the time to program a ATTiny85 and breadboard it up with the screen. I wanted to make sure the big parts were ready and working for when the boards showed up. I almost wired up buttons, but it was about 2:00am and it was time for some slumber. 

IMG 0994

I was giddy at work just itching to get home and put all of the parts together and play some Tetris. And to be honest it has been quite a while since I have played it. Alright already, all of the parts are laid out and the iron is hot. 

IMG 0991

IMG 0992

 

 

 

 

 

 

 

 

 

There I go. It took about an hour to get it all soldered up. I was trying to be extra nice, and neat. While my soldering skills are markedly better than they were a year ago, practice makes perfect and I am still working towards that goal. Once it is done the big moment, time to slide in the battery. I rummage in the battery drawer and pull out a CR2032 and pop it in. And nothing. 

Really, nothing. Take it out and make sure I have positive facing up, yup. One more try and nothing. I pulled out my multimeter and check the battery 2.1V. Doesn’t that figure and I wait another day as it is again about 1:30am’ish (I work second shift so tend to have late hours in the studio). 

I grab a two pack early the next morning and try it again. NOTHING! Well shit and shoved in it Wilbur I am getting a little annoyed by this time. I pull out my meter again and start checking continuity and don’t find any issues. I put the battery back in and start checking my voltages. All the pins have power and reading at the correct levels. WTH?

I sit down and start doing a little web surfing while keeping a picture of the Pocket Tetris on my screen. What could be wrong? Well it is a funny little story about CAREFULLY checking what pins go where and which pins you have there after staring at one’s problem for a good long while. There was a dope slap and a DOH! involved when I saw it. 

IMG 1064

Now this simple, fun, quickie project will have to wait a little while longer. That was my only spare screen and I don’t have a solder sucker (yet). So while another slow boat makes its way here with new screens, with the CORRECT pinouts, and a solder sucker I have other projects to move onto. New high scores will have to wait for another day. 

A.D.D. has kicked in

I have been busy with 4 different projects, one done and the rest coming along. I seem to bounce back and forth as I ponder over some design flaws and possible solutions. Which usually leads to a “hey let’s do this too” moment, I like to call it my Shiny Penny Syndrome. It works for me. 

Click on the project title to to the that projects link if you wish. 

Bluetooth Speaker

We need a bluetooth speaker for the outside by the pool and I have also wanted one to use inside the house as well. This one is 90% complete. I still need to find what I am going to use for front and back grills. I may settle for some black material on a frame for the front and some aluminum grill for the back. In the meantime at least it is ready to go!

 

IMG 9806

Volumio Case

While the Volumio is up and working in the family room downstairs, I am still working on the case for the setup. I have the idea firmly in my head. I have the case hollowed out. I need to find a way to get down to the bottom and clean and smooth the bottom. it is too small to work it with any chisel I have. I was thinking of upping the RPMs on my drill press and using the drill bit to clean it out. We’ll see, I still have a little research to do on this one. 

  

IMG 9863

Arduino CNC experiment

My goal here is to have a larger CNC mill, a real one, that can handle wood and soft metal like Al and brass. While I usually like to jump into a project with both feet, I have learned and bit by over enthusiasm in the past. I have read quite a few builds using old DVD drives, the LM293, and an Arduino to make a simple X / Y potter (the Z axis raises and lowers the pencil). I have the X axis works, the Z axis servo works when it feels like it (so much for the cheap micro servos in the intro kit. Time to scavenge from an old RC car tonight). The Y axis just grinds at me, so I need to dig into it here tonight and get it moving, literally. 

IMG 9871

RetroPie

This is one that was downloaded, installed, configured, setup with 2 controllers, an old LCD monitor, and it has been hard to find to time to play with it myself. That is OK it is being well used. I have an audio DAC for the Pi 3 some old monitor speaks to mate with it. I have been searching for a case idea. The cases one can purchase are well – so so, do in a pinch, rather not spend money on one, will the HAT fit? As I pondered and searched, I stumbled upon an old Game Cube for sale on eBay (9 bucks right now, don’t bid on it please) and it looks like it will do the trick quite nicely. Integrated power supply, spaces for controllers / USB ports, and about the right size. I hesitated when I click on bidding for it, but as time goes and I read some, it should work quite nicely. Stay tuned for where this one ends up. 

Tempest Spinner

Since the RetroPie is up and going, I have been playing some Tempest, my ALL time favorite arcade game; but it just isn’t right playing it with a controller, keyboard, or mouse. One really must have a spinner for the real experience. I have looked for them online, but they are rather pricey (upwards of $70.00) so I have been looking into making my own. I have the box of parts and my notes in line. I will find some time one night when nothing else interests me 😉 I guess you will just have to check back on this one to see how it goes. 

 

 

 

ATTiny Dice

Early on in my adventures in the micro controller world, one of my goals has been to usher an idea from paper, to breadboard, to protoboard, to real PCB board. After a long night of soldering, I decided to take a break and start the post about it all.

I learned early in life, start simple and build on what you know. In that vein I took the idea of making digital dice. To date I am up to the photo-board phase. I am making an actual die I can give as presents for this Christmas season.

I had an idea how to start the project. I grabbed my Arduino Uno, 7 LEDs, and my breadboard. 7 lights, 7 pins, and away I went. After a giggle of joy over seeing it work, I stared at it wondering how I was going to make a box that looked reasonable to fit the Uno as a die.

That idea was quickly nixed. In my readings and forum lurkings I had heard of the different chips in the ATmel family of microprocessors. With a little digging I soon found the ATtiny85 which seemed like it would fit the bill I was looking for. Small footprint, just a few pins, and it works with my Arduino Uno knowledge. Dang, I have 7 LEDs with 7 pins and this little guy sure doesn’t have enough, or does it.

While awaiting my ATtiny order, I used the time to research a little more about this new turn I took (with little foreknowledge it should work). I also waded through the data sheets for the ATTiny family to find out more of their capabilities. You can find the information here. There is a method to control more than 1 LED pre pin. The method is known as Charliplexing. Here is an example to get you going.

With a little more knowledge in hand it is time to draw out how one might control the LEDs. Knowing how a die is made with the numbering scheme as dots we need a total of 7 to replicate what an actual one looks like and how they will light up in turn.

Now that I had my little 85’s in hand I took to the breadboard to see what I could come up with. It took a couple of tries to a) double and triple check my wiring (make sure ground is going to ground!) b) at the same time learning how to program the ATTiny.

So, here is where there is a branch (one I kinda of started already). I am going to take a quick detour on the ATtiny85. I know that the ATT85 is part of the Atmel family of microprocessors. The ATT85 has fewer pins, less memory, less power, and slower. None of these are an issue for this project and in all ways a big plus as I want this project to be small in size. There are breakout boards and programming boards one can use to program the ATtiny85 such as the Digispark, and there is the use what you have it works pretty darn well method too. I went with the later of them. Here is one of the sites I researched when planning on how to get my code on the ATTiny85.

With the Uno it is as straight forward as connecting it to my Mac with a USB cable and upload the sketch. With the ATtiny85, I used the Uno as the ISP

The wiring is pretty straight forward, just follow the diagram. If it is your fist time trying this out, the blinking LED exercise if a good one; if for nothing else getting you used to setting up and uploading code to it.

 

On the right hand side of my breadboard you can see the ATTiny85, wire up and running the die code. In this version I am using a button switch instead of the motion switch.

It works. I have my ATtiny85 programmed with my die code, wired up to the LEDs, and it is working! I have that giddy feeling all over again, but than the sigh. Even if I get a small breadboard it still won’t look quite right. I guess it is time for another plunge and learning experience. That is a good deal of why I started tinkering in this digital world.

I knew what was next, I had to solder it all on some protoboard. You know those green or tan sheets with holes (well some have holes predrilled) that you can solder little parts onto. I made out my list of parts and pulled them all before I began. This hasn’t been your weekend type project. Between family, work, and other of life’s bits it has taken me a few weeks by now. And those boats from China really are slow!).

BOM (Bill of Materials)

1     Protoboard

1     ATTiny85 (read a little lower for more on this choice)

7     LED, 5mm

1     Motion switch

1     Various 24AWG solid core or stranded wire

This is my first try at a full-on, solder it up type project. I didn’t think I would get it right on the first try, but Oye Vey! It almost worked, but my voltage readings were waaaaaay low by time I measure at the LED pins. Oh well, I will not be deterred and try again.