This project was to generate a composite video signal on a CRT television, using only a microcontroller and the most minimal supporting hardware possible. After much study, I did in fact accomplish it!

Using an ATMega8 running at 4mhz, I was able to generate a display entirely via software with a resolution of 64x48 pixels, and four shades of gray.

After the initial display tests, and then scrolling text, I eventually evolved the project to play Pong, complete with a paddle controller made of a simple potentiometer, and even a speaker to emit primitive beeps.

It takes 768 bytes for video memory, since each pixel takes 2 bits (allowing four possible colors, of black, white, and two shades of gray). The ATmega8 I used to do all of this only has 1KB of RAM, which is a huge limitation in the quality of the video it can generate. It's possible to generate higher resolution video lines on the fly if one wanted, but that's too much like Atari 2600, where you figure out what to draw on each line when you get to it. I just wanted a bitmap-based display, where I could have a code loop running which just writes pixels to memory locations, and then the video interrupt handles displaying that independently.

If you went to 1-bit-per-pixel, that would still just allow something like 128x48 resolution with the way things work now, and limit you to just two colors. Even using every single byte of RAM and limiting the functionality of the game code would manage 128x64. Just not worth the limitations it would cause.

The sound is a simple square wave generated by one of the PWM channels of the chip. Not much needed externally for that, aside from resistors to limit the output and a capacitor for coupling. Though since it uses the same pin as one of the connections used for programming it, I had to stick a diode in too. Every time I program it now I hear a neat little electronic spurt through the speaker briefly.

Source Code