Tuesday, March 22, 2011

Project 22 - LED Dot Matrix Display - Pong Game

After downloading the LedControl library and extracting it into the Arduino library folder, I uploaded the very simple program for project 22 to my Arduino. The only modification I made to the circuit built in Project 21 was adding the single potentiometer... mine is a 5k instead of the 10k specified which seems to make the response a little bit less reliable... no big deal as I totally understand the program and how it works.

I really have a new appreciation for those old-time programmers who had to code up all this stuff with limited memory, limited video controls, etc... makes all those years play Atari 2600 games seem even more fun.

An 8x8 LED is definitely going to limit what you can do in terms of games, but you can see how a larger display such as the LoL Shield expands your opportunities. I'm now looking forward to learning more about the LCD screen in the next chapter as it has a higher resolution and, apparently, less wiring and coding to get stuff displayed properly. (Reading ahead, I'm hoping that my 16x2 LCD is compatible with the HD44780 driver the author mentions in Chapter 8. Will find out shortly)

Below is a video of the Pong Game... trying to control the paddle with one hand while holding the camera is difficult, so don't laugh at the results!

Friday, March 18, 2011

Project 21 - LED Dot Matrix Display - Scrolling Message FIXED

This project's been driving me crazy... the code makes total sense and I couldn't find any errors with my wiring.

So I just knew it had to be a bad chip or a bad 8x8 display... because there's simply no way it could be my mistake, right?

Well, if I'd looked at the very small writing on the side of the 8x8 display I would have seen the letters TA15... on the other 8x8 are the letters TC15... I wonder what those letters mean?

This project calls for a Common Cathode... with a C. Earlier projects used a Common Anode 8x8... with an A. Hand. Hits. Head. Hard.

So, here it is... with the proper 8x8 display installed... and working fine.

I'm going to go to bed early tonight.

Wednesday, March 16, 2011

Project 21 - LED Dot Matrix Display - Scrolling Message

In the continuing story of 8x8 LED displays not working for me, Project 21 is no different. I've checked, double-checked, and triple-checked my wiring and can find nothing wrong with it.

I'm using the C- display as specified, but all I can manage is to get a nice little light display on the 8x8. There is something going on... just not sure what it is.

There also was a little bit of extra code in the program that I had to remove and fix in order to even upload the program to the Arduino. I'm including a screen capture here - there's a small symbol indicating wrap-around of the code... remove it, hit the delete key to pull the little bit of wrap-around code back to the previous line... and the program at least uploads properly.

I also did a side by side comparison of the data sheet for my 8x8... compared it to the author's and it's identical (see screen capture). You can view my data sheet here.

I'm using the small 8-pin headers to raise the display off the breadboard - I've made certain that all the pins are connecting properly but given that all the LEDs light up, I don't think there's an issue with the headers. My best guess is a wiring problem that I'm just not seeing or maybe a damaged IC, although I was very careful when handling the MAX7219 chip.

I'm going to play around with the wiring a bit and take a more detailed look at the data sheet as I think that may be my issue.

Tuesday, March 8, 2011

Project 20 - LED Dot Matrix Display - Scrolling Sprite

Well, I feel much better today - I was able to rule out my wiring, chips, and 8x8 display as the problem. I was reading ahead into Project 20 that uses the same wiring setup as Project 19. I took a chance and loaded the Project 20 program and - BAM - it works! (See first video below.)

Next, I copied a fresh version of the Project 19 code from the zip file containing all the book's programs (just in case I'd accidentally modified the code or something)... after loading it, I got the same error - a single flashing row along the top of the 8x8 display (see second video).

means that the program for Project 19 definitely has an error... but I've gone over and over it and cannot find the mistake. Maybe a reader can spot it?

Either way... I'm happy that Project 20 is working and it's a fun little exercise to go over. I've always wondered about "sprites" and "multiplexing" when it comes to game design (I've heard the terms often) and I think my understanding just increased a good bit.

BTW - Project 19 text describes the program as displaying a heart and then inverting it (page 132, 3rd paragraph under "Enter the Code") - but if you look at the actual program, the sprite stored is just a box in a box... the ones represent solid lines so you'll see there's an outer box made up of the outer LEDs and then a smaller inner box. Not sure if this is a major error in the book and means that the actual working program for Project 19 wasn't included (heart) but this box-in-a-box program was inserted in its place.

Sunday, March 6, 2011

Project 19 - LED dot Matrix Display - Part 2

I ended up using a set of headers to raise the 8x8 display about .5cm off the breadboard... it was just enough to allow me to use my jumper wires (the non-flexible ones).

My next task was to upload the Project 19 code... I did that and only the top row of the display lit up... and it was very faint. Not sure what was going on, I took off the display and went to work checking all my wiring. The next time testing the display... still no luck.

It occurred to me that the only difference between Project 19 and the previous Project 18 was I was simply dealing with more LEDs. I had a hunch, so I loaded up the Project 18 code and wouldn't you know it... the display worked great! Watch the video - just pay attention to the top row and nothing else... you can see that it starts out with all LEDs lit up (value 255) and then counts down in binary to 0...

So, a few things here - (1) my wiring must be at least partially correct or I wouldn't have that kind of behavior and (2) because you can almost see the pattern in the vertical (column) orientation as well (watch the last column in the video - farthest from the left), I believe that both 595 chips are working properly.

So... why isn't the code for Project 19 working? Not sure... I downloaded the TimerOne library, created the TimerOne folder, and put the files in it... no errors found when the code downloads, so it must be finding the library, right?

I'm not sure where to go here - I'm wondering if there might be something wrong with the author's code... I doubt it, because so far all the programs appear to have been well tested and I can't imagine a tech editor for this book not verifying all the programs and that they work. One issue I did have was that the author uses TimerOne for the library name but you can see "Timer1.xxxx" in the code... I'm not thinking this is an issue, but I can't say for certain.

Any ideas? I'm going to go and check my wiring one more time, but I just can't see that being the issue.

Friday, March 4, 2011

Project 19 - LED dot Matrix Display - Part 1

I'm quickly learning that when you work with electronics it's best to do so when your frustration level is low...

Thankfully, when I opened up my new box of goodies from SparkFun (who, once again, managed to package 10 items in a 4"x5" box - love it), I was in a good mood. Here's what happened from there...

First, I found the data sheet for my 8x8 Dot Matrix Display (C+) - feel free to take a look at it here. I'm including a few screen caps here of the data sheet to show you that the pin layout matches exactly the one that the author provides on page 132 in Figure 7-2. Woo Hoo... I won't have to worry about modifying the code due to pin differences.

Next, the data sheet was very clear on how to find pins 1-8 and 9-16... the small display has two notches that are raised and two notches that are recessed. If you turn the display so that the two raised notches are on the S and W edges, pins 1-8 are on bottom and 9-16 are on top.

Once I figured that out, that's when I hit the bump in the road... as you can see from one of my photos here, when you insert the display on the breadboard, the pins are inserted at the topmost set of pin holes and the bottom-most set of pin holes, leaving no holes for jumper wires. Figure 130 shows the display with two rows of free pins below the display and one row of free pins above the display... and that's my problem. Not sure if the author actually had an 8x8 display that didn't come in a shell like mine or if the display found in the program, Fritzing, doesn't take the shell into account when it comes to proper spacing... either way, I'm unable to wire up Project 19 until I find a work around...

One option is to solder some longer wires to each of the pins on the display and then I can insert these and leave the display free-floating off of the breadboard.

Another option I'm considering is using headers (I have a bunch from the Make: Electronics book project) and solder wires onto those - this would save my display's pins and leave them unaltered.

Thoughts from my readers? Any other suggestions?