自己做的车辆动态称重系统 自己写的程序 怎么运行部出来?求大神帮忙 谢谢 下面附程序和硬件图
#include ***it RS=P2^0; ***it RW=P2^1; ***it E=P2^2; unsigned char code str[]={"Volt:"}; unsigned char code strl[]={"weigh:"}; void Delay(unsigned int t) { unsigned char i,j; for(i=0;i for(j=0;j<110;j++); } void wr_command(unsinged char com) { Delay(1); RS=0; RW=0; E=0; P0=com; Delay(1); E=1; Delay(1); E=0; } void wr_data(unsigned char dat) { Delay(1); RS=1; RW=0; E=0; P0=dat; Delay(1); E=1; Delay(1); E=0; } void locateXY(unsigned char x,unsigned char y) { if(y==0) x|=0x80; else x|=0xc0; wr_command(x); } void Init_LCD() { Delay(15); wr_command(0x38); Delay (5); wr_command(0x08); Delay (5); wr_command(0x01); Delay (5); wr_command(0x06); Delay (5); wr_command(0x0c); Delay (5); } void Display_str(unsigned char ﹡p) { while(﹡p!=’ ’) { wr_data(﹡p); P++; Delay(1); } } void Init_display() { Init_LCD(); locateXY(0,0); Display_str(str); locateXY(0,1); Display_str(str1); } #include "0804.h" #include "1602.h" #include ***it int1=p3^3; ***it cs=p3^2; ***it wr=p3^6; ***it rd=p3^7; ***it LED=p2^3; ***it sound=p2^4; void Delay_0804(unsigned int tc) { while(tc!=0) { unsigned int i; for(i=0;i<100;i++); Tc--; } } unsigned char adc0804(void) { unsigned char addata; rd=1; wr=p3^6; wr=1; int1=1; P1=0xff; cs=0; wr=0; wr=1; while(int1==1); rd=0; Delay_0804(1); addata=P1; rd=1; cs=1; return(addata); } unsigned int datpro(void) { unsigned char x; unsigned int dianyah,dianyal; unsigned int dianya=0; for(x=0;x<10;x++); { dianya=adc0804(); } dianya=dianya/10; dianyah=dyanya&0xf0; dianyah=dyanyah>>4; dianyal=dianya&0x0f; dianya=dyanyal﹡20+dianyah﹡320; return(dianya); } display_0804() { unsigned int dat=0; unsigned int weigh=0; dat=datpro(); weiggh=dat/5; locateXY(6,0); wr_data(dat%1000/100+0x30); wr_data('.'); wr_data(dat%100/10+0x30); wr_data('V'); locateXY(7,1); if((weigh/100+'0')==0x30) wr_data(0x20); else wr_data(weigh/100+'0'); wr_data(weigh%100/10+'0'); wr_data('.'); wr_data(weigh%10+'0'); wr_data('t'); while(dat>=400) {LED=0; Delay(100); sound=0; Delay(100); } }
麻烦大神看看 |