完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
//USE ONE KEY TO TEST 5 CHANNELS VOLTAGE //USE PIC16F74-DIP LCD12864 //USE 16MHZ CRYSTAL #include #define uchar unsigned char #define uint unsigned int #define PORT_LCD_DAT PORTB #define TRIS_LCD_DAT TRISB #define _XTAL_FREQ 16000000UL//16MHZ OSC,CODE PERIOD 0.25US PER #define RS RD7//LCD PORT CONTROLL #define E RD6 #define beep RE2 #define key0 RD1 #define key1 RD0 #define key2 RC3 #define key3 RC2 //const uchar table[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};//0-9 ASCII CODE const uchar table[]="0123456789"; uint voltage; uint result; uchar adflag=1; void delay(uint); __CONFIG(0X0002);//HS CRYSTAL void delay(uint z) //DELAY FUNCtiON { uint x,y; for(x=z;x>0;x--) for(y=100;y>0;y--); } void write_lcd_command(uchar cmd)//LCD WRITE COMMAND FUNCTIONS { RD6=RD7=TRISD6=TRISD7=0;//SETTING PORT AS WRITE DIRECTION RS=0; TRIS_LCD_DAT=0X00; PORT_LCD_DAT=cmd; delay(6); E=1;delay(6);E=0; } void write_lcd_data(uchar dat)//LCD WRITE DATA FUNCTIONS { RS=1; TRIS_LCD_DAT=0X00;//SETTING PORT AS WRITE DIRECTION PORT_LCD_DAT=dat; delay(6); E=1;delay(6);E=0; } void lcd_initialize()//LCD INITALIZTIONS { write_lcd_command(0x30); write_lcd_command(0x01); write_lcd_command(0x06); write_lcd_command(0x0f); } void lcd_showstring(uchar r,uchar c,char *str) { uchar i=0; if(r==0) write_lcd_command(0x80|c);//LCD NO.1 else if(r==1) write_lcd_command(0x90|c);//LCD NO.2 else if(r==2) write_lcd_command(0x88|c);//LCD N0.3 else if(r==3) write_lcd_command(0x98|c);//LCD NO.4 for(i=0;i<16&&str[i]!=' |