Sounds like a job for a microcontroller. Check out www.avrfreaks.net for info on the Atmel AVR family of microcontrollers, which are relatively cheap ($5-$15 per chip, with a $80 initial investment for a programmer board, although I understand you might be able to build your own for cheaper, or use a Butterfly demo board). Might be easier ways to do it, but I'm not an electronics guy, I'm just getting into the whole microcontroller thing myself.