void main()
{
unsigned int analog;
TRISA=0xFF;
TRISB=0;
TRISC=0;
PORTB=0;
PORTC=0;
while(1)
{
analog=Adc_Read(3);
if(analog>0&&analog<=64)PORTB=0x80;
else if(analog>64&&analog<=2*64)PORTB=0xC0;
else if(analog>2*64&&analog<=3*64)PORTB=0xE0;
else if(analog>3*64&&analog<=4*64)PORTB=0xF0;
else if(analog>4*64&&analog<=5*64)PORTB=0xF8;
else if(analog>5*64&&analog<=6*64)PORTB=0xFC;
else if(analog>6*64&&analog<=7*64)PORTB=0xFE;
else if(analog>7*64&&analog<=8*64)PORTB=0xFF;
else if(analog>8*64&&analog<=9*64)
{
PORTB=0xFF;
PORTC=0x80;
}
else if(analog>9*64&&analog<=10*64)
{
PORTB=0xFF;
PORTC=0xC0;
}
else if(analog>10*64&&analog<=11*64)
{
PORTB=0xFF;
PORTC=0xE0;
}
else if(analog>11*64&&analog<=12*64)
{
PORTB=0xFF;
PORTC=0xF0;
}
else if(analog>12*64&&analog<=13*64)
{
PORTB=0xFF;
PORTC=0xF8;
}
else if(analog>13*64&&analog<=14*64)
{
PORTB=0xFF;
PORTC=0xFC;
}
else if(analog>14*64&&analog<=15*64)
{
PORTB=0xFF;
PORTC=0xFE;
}
else if(analog>15*64)
{
PORTB=0xFF;
PORTC=0xFF;
}
else
{
PORTB=0;
PORTC=0;
}
}
}
{
unsigned int analog;
TRISA=0xFF;
TRISB=0;
TRISC=0;
PORTB=0;
PORTC=0;
while(1)
{
analog=Adc_Read(3);
if(analog>0&&analog<=64)PORTB=0x80;
else if(analog>64&&analog<=2*64)PORTB=0xC0;
else if(analog>2*64&&analog<=3*64)PORTB=0xE0;
else if(analog>3*64&&analog<=4*64)PORTB=0xF0;
else if(analog>4*64&&analog<=5*64)PORTB=0xF8;
else if(analog>5*64&&analog<=6*64)PORTB=0xFC;
else if(analog>6*64&&analog<=7*64)PORTB=0xFE;
else if(analog>7*64&&analog<=8*64)PORTB=0xFF;
else if(analog>8*64&&analog<=9*64)
{
PORTB=0xFF;
PORTC=0x80;
}
else if(analog>9*64&&analog<=10*64)
{
PORTB=0xFF;
PORTC=0xC0;
}
else if(analog>10*64&&analog<=11*64)
{
PORTB=0xFF;
PORTC=0xE0;
}
else if(analog>11*64&&analog<=12*64)
{
PORTB=0xFF;
PORTC=0xF0;
}
else if(analog>12*64&&analog<=13*64)
{
PORTB=0xFF;
PORTC=0xF8;
}
else if(analog>13*64&&analog<=14*64)
{
PORTB=0xFF;
PORTC=0xFC;
}
else if(analog>14*64&&analog<=15*64)
{
PORTB=0xFF;
PORTC=0xFE;
}
else if(analog>15*64)
{
PORTB=0xFF;
PORTC=0xFF;
}
else
{
PORTB=0;
PORTC=0;
}
}
}