Archive for September, 2011

Imperial March on atmega16

I sat down to do one of my micro-controller labs for uni today and noticed we had to play a single tone using PWM. “Easy” I thought. Keep reading. Until I get to the final part of the lab. it was basically “Load this HEX file and play it. It plays a musical piece” .
I was a little let down…
I mean, I was fully expecting it to ask us to write the program ourselves to play a given song, but no. Here it was just giving us the HEX file to load and play.
I wasn’t going to let this deter me. I had it in my head to have this thing play The Imperial March by John Williams from Starwars.
Mate and I got together, and off we went.

It’s a relatively simple program. 2 arrays holding the frequencies and durations of each note, PWM output, and a loop to play each note in sequence, and then start again.


Easy as!
Here’s the source code for anyone interested.

Source Code

This uses about 50% of the atmega16’s memory, becuase of the arrays. So keep that in mind while writing new songs!

Have a go yourself! Port some new songs into chiptunes!
Post your results!


So, I’ve had a bit of an intermittent right bumper on my Nintendo DS Lite for a while now, but a few months ago, it gave up the ghost. Far too much Bleach: The Blade of Fate, and Tetris. Forever Tetris.
My mate and I, whenever we see each other, we play Bleach for hours on end. Never listen to him, I win. BUT! My right bumper broke, and it’s quite hard to win at a fighting game without a block button.

So. It broke on a train on my way home from Sydney. We tried re mapping the block button, mashing the button hoping that it would start working again. To no avail.
Oh well. Mario Kart it is then.
Then it just went to the back of my mind and wasn’t thought about again. Until a few nights ago.
Talking to my mate “Why don’t you just pull it apart and fix it?”
Challenge Accepted.

Hit up Ebay, get me a Tri-wing screwdriver to open Nintendo products. 2 days later, my DS was on pieces on my desk.
Test, test, test. What do I find out? The actual button is fried. Not the bumper playing up. The button has died.
Well. There goes that button. But hang on! I have a couple of spare SPST momentary switches lying around! Surely I can hack one onto the board!

And do that, I did…Here are the results…

I ah…Think I also burnt off a resistor just below the bumper…But it hasn’t affected the operations of my DS what-so-ever. Well, we’ll see in the long run if anything happens.
Enjoy my little triumph, and remember, if it’s broke, it can be fixed. And if it’s not broke, then it still needs fixing.


EDIT: Turns out my power LED has stopped working…Hence, I have no idea when it’s running out of power…
That’s really odd. It was working last night… That could be what the resistor was, but, the LED wouldn’t have worked last night… Hot glue isn’t conductive is it? I don’t think so…
This makes Phill a sad panda.

EDIT AGAIN: Turns out it was the current limiting resistor for the red LED that warns of low battery. The green power and orange charging LED still work perfectly. So i’ll just have to remember, if no LED is on. It’s either not on at all, or it needs charging…