We are going to start with a very simple program. We are effectively considering the replacement of a simple astable circuit. An astable is a circuit which is constantly changing between to states. If you make one of these states turn a light on, and another turn it off, you have a flashing light. You can create an astable with a couple of transistors and a bunch of capacitors and resistors but we are going to use a PICmicro which we will program to do the job. This may sound like overkill, in that a PICmicro contains many thousands of transistors. However, it is actually not as stupid as it sounds, in many situations you now find tiny computers which are programmed to do jobs which would once have been performed with discrete components. Working this way is becoming the cheapest way to do the job.

We will solve the problem by doing the following in sequence:

  • Discover how we need to set the PIC up

  • Find a way to turn a LED on

  • Find a way to turn a LED on and off

  • Get the program to loop around so that the LED flashes

To do this we will look at a number of C language constructions, as well as consider how the C program actually executes on the computer.