This is a simple program that can be merged with other sources to allow easy in-circuit debugging.
When you’re writing a program for a normal computer and it isn’t quite doing what you want it to do you simply print some variables to the screen to see what’s going on. Since microcontrollers don’t have a screen these debugging variables will have to be printed on the screen of the PC.
As a test I used the following schematic. It features two analog inputs on port A, a0 and a4, both equipped with a 10k LIN variable resistor. On port B b1 is a digital input with a 10k pull down resistor, and port C c4 has a digital output with a LED attached to it.
The test program uses all the inputs and outputs (otherwise it would have been rather useless to built the entire schematic, wouldn’t it), and it has an internal counter. This counter is incremented at each loop and will light the LED as soon as the counter exceeds 100. Since the variables restart at 0 after 255 is reached the LED will actually flash.
Visit Here for more.