PIC code for the RGB Lamp is written in C and compiled using the MPLAB X cross-platform IDE and the HI-TECH C compiler.

The lamp code uses a simple event driven strategy. Events are generally initiated through hardware events. Application logic is structured as a set of tasks, each of which is executed in response to a given event. Because much of the behavior of the lamp application is dependent upon timing, a timer abstraction is also useful.

So, this code uses both of these useful abstractions: tasks and timers. This project hacks together some basic support for tasks and timers for the PIC16. Thankfully the atypical architecture of the PIC16 is mostly abstracted by the C compiler. And because this is such a simple project, the simplistic interrupt handling of the PIC16 is not an issue either. And although not very flexible in its use, driving Timer 1 via a 32 kHz crystal offers reasonable support for auto-on from soft off.

The project yielded some other other novel tidbits.