自己用HX711做了称重设备 怎么不显示?
时间:10-02
整理:3721RD
点击:
自己用HX711做了称重设备 怎么不显示? 麻烦各位大神帮忙看看 谢谢 程序如下
- #include<reg52.h>
- #include<intrins.h>
- #include<stdlib.h>
- #include<stdio.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define ulong unsigned long
- int weight;
- //double money;
- int temp;
- char button;
- sbit lcdrs=P2^4;
- sbit lcdwr=P2^5;
- sbit lcden=P2^6;
- sbit hx711_dout=P2^0;
- sbit hx711_sck=P2^1;
- sbit spk=P2^2;
- //1602显示程序
- void delayms(int k)
- {
- int i,j;
- for(i=k;i>0;i--)
- for(j=110;j>0;j--);
- }
- void write_com(uchar com)//写命令
- {
- lcdrs=0;
- P0=com;
- delayms(5);
- lcden=1;
- delayms(5);
- lcden=0;
- }
- void write_date(uchar date)//写数据?
- {
- lcdrs=1;
- P0=date;
- delayms(5);
- lcden=1;
- delayms(5);
- lcden=0;
- }
- void init_1602()
- {
- lcden=0;
- //lcdwr=0;
- write_com(0x38);//设置16x2?显示5x7点阵,8位数据接口?
- write_com(0x0c);//设置开显示,不显示光标?
- write_com(0x06);//写一个字符后地址指针加1?
- write_com(0x01);//显示清0,数据指针清0?
- }
- void displaywpm(void)
- {
- uchar num;
- uchar code table[]="W:kg";
- write_com(0x80);
- write_date(table[0]);
- write_date(table[1]);
- write_com(0x80+0x07);
- write_date(table[2]);
- write_date(table[3]);
- write_com(0x80+0x0a);
- write_date(table[4]);
- write_date(table[5]);
- write_com(0x80+0x0f);
- write_date(table[6]);
- write_com(0x80+0x40);
- for(num=0;num<6;num++);
- write_date(table[num+7]);
- write_com(0x80+0x4a);
- write_date(table[13]);
- }
- void weight_shuzhi(uint aaa)
- {
- uchar idata weighttable[4]={0,0,0,0};
- weighttable[3]=aaa%10;
- weighttable[2]=aaa/10%10;
- weighttable[1]=aaa/100%10;
- weighttable[0]=aaa/1000;
- write_com(0x80+0x02);//设置显示位置?
- write_date(0x30+weighttable[0]);
- write_com(0x80+0x03);//设置显示位置?
- write_date('.');
- write_com(0x80+0x04);//设置显示位置?
- write_date(0x30+weighttable[1]);
- write_com(0x80+0x05);//设置显示位置?
- write_date(0x30+weighttable[2]);
- write_com(0x80+0x06);//设置显示位置?
- write_date(0x30+weighttable[3]);
- write_com(0x0c);//不显示光标
- }
- //hx711程序 //
- void Delay__hx711_us(void)
- {
- _nop_();
- _nop_();
- }
- ulong ReadCount(void)//增益128
- {
- ulong count;
- uchar i;
- hx711_dout=1;
- Delay__hx711_us();
- hx711_sck=0;
- count=0;
- while(hx711_dout);
- for(i=0;i<24;i++)
- {
- hx711_sck=1;
- count=count<<1;
- hx711_sck=0;
- if(hx711_dout)
- count++;
- }
- hx711_sck=1;
- Delay__hx711_us();
- hx711_sck=0;
- return(count);
- }
- //主函数//
- void main()
- {
- init_1602();
- displaywpm();
- while(1)
- {
- get_weight();
- if(weight>0)
- {weight_shuzhi(weight);}
- else
- {weight_shuzhi();}
- displayprice();
- }
- }
哈哈哈哈哈哈哈哈
看看是不是电路接错了
哈哈哈, 不会,也准备做一个。
你好,你这个调试出来了吗
