哪位能给改正修改下,谢谢!
#include<pic.h>
#define uchar unsigned char
#define uint unsigned int
__CONFIG(0x3B31);
void delay(uint x);
void init();
void disp();
uint get_ad();
void main()
{
uint lednum;
init();
while(1)
{
GPIO=get_ad();
}
}
void delay(uint x)
{
uint a,b;
for(a=x;a>0;a--)
for(b=110;b>0;b--);
}
void init()
{
TRISIO=0x01;
GPIO=0x00;
ANSEL=0x71;
ADCON0=0x81;
delay(10);
}
uint get_ad()
{
uint adval;
ADCON0=0x02;
delay(10);
while(ADCON0==0x00);
TRISIO=0x01;
adval=ADRESL ;//00000011
return (adval);
}
|