You might also find this useful:
Although it is about flashing LEDs the principles are the ones you need to learn.