PIC Code description:
The main program loop waits for a serial data received flag to be set. if a valid command terminating with a $ is received the string is processed and values for RGB are set. Timer two generates an interrupt every 128us. The interrupt code consists of a counter that counts from 0-50. All the outputs are switched on initially. if the number set matches the counter the individual output is switched off. This is done for all the 3 outputs. 128 * 50 = 6400us or 6.4ms for the cycle to complete. or 156.25Hz
if Motor 1 =10, Motor 2 = 30, and laser = 5, the waveform will look like:
Motor 1 = |¯¯¯¯¯¯¯¯¯¯|________________________________________|
Motor 2 = |¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|____________________|
laser = |¯¯¯¯¯|_____________________________________________|
|