Marioduino

I recently acquired an Arduino Duemilanove, and my first shield arrived yesterday - a Nokia 3310 LCD Shield. The documentation was was a somewhat scarce for that particular shield, but it did the job.

Once the obligatory "Hello, World!" program was written, I began writing this program. Mario was going to run across the LCD screen while Super Mario Bros. tune was playing on the speaker.

Not having a musical note in my head, I had to have a google for the tone generation element of this project. This was the easy part. Just connect a speaker between a PWM digital output and ground.

The hard part was not actually the coding of the animation, but rather the conversion of the SMB sprite images that I had found online to monochrome bitmaps for the LCD. None of the programs that I tried (Paint.net and GIMP) had any decent dithering options so I had to convert each image to monochrome by hand. The main problem was trying to get continuity between the frames with the dithering. In the end, lots of ctrl+tabbing between the three images and careful inversion of troublesome pixels was all that was needed.

Once the 84x48 monochrome bitmaps were ready, I used a java program to convert the bitmap images to an hex array to to be stored in the ATmega328 flash memory. When that was done, the three hex arrays were placed into an accompanying header file to keep the program source code clean. The source code is attached below.

marioduino source code

One thought on “Marioduino

Leave a Reply