main()
{
PORTA = 0;
CMCON0 = 7; // Turn off Comparators
ANSEL = 1; // Just RA0 is an Analog Input
ADCON0 = 0b00000001; // Turn on the ADC
// Bit 7 - Left Justified Sample
// Bit 6 - Use VDD
// Bit 4:2 - Channel 0
// Bit 1 - Do not Start
// Bit 0 - Turn on ADC
ADCON1 = 0b00010000; // Selemct the Clock as Fosc/8
while(1 == 1) // Loop Forever
{
for (i = 0; i < 8; i++ )
{ // Loop through Each of the 8 LEDS
for (j = 0; j < Dlay; j++); // Display "On" Delay Loop
if ((ADCValue & (1 << i)) == 0)
PORTA = NOTPORTA[i];
else
PORTA = PORTAValue[i];
TRISA = TRISAValue[i];
} // rof
switch (ADCState) // ADC State Machine
{
case 0: // Finished, Start Next Sample
GODONE = 1;
ADCState++;
break;
case 1: // Wait for ADC to complete
if (!GODONE)
ADCState++; // Sample Finished
break;
case 2: // Save Sample Value in "ADCValue"
ADCValue = ADRESH;
ADCState = 0;
break;
} // hctiws
} // elihw
} // End