基于单片机的电子秤设计 (5kg)
void main()
{
Uart_Init();
Send_Word("Welcome to use!\n");
Send_Word("Made by Beetle Electronic Technology!\n");
Init_LCD1602();
LCD1602_write_com(0x80);
LCD1602_write_word("Welcome to use!");
Delay_ms(1000); //延时,等待传感器稳定
Get_Maopi(); //称毛皮重量
while(1)
{
EA = 0;
Get_Weight(); //称重
EA = 1;
Scan_Key();
//显示当前重量
if( Flag_ERROR == 1)
{
Send_Word("ERROR\n");
LCD1602_write_com(0x80 0x40);
LCD1602_write_word("ERROR ");
speak=0;
}
else
{
speak=1;
Send_ASCII(Weight_Shiwu/1000 0X30);
Send_ASCII(Weight_Shiwu%1000/100 0X30);
Send_ASCII(Weight_Shiwu%100/10 0X30);
Send_ASCII(Weight_Shiwu%10 0X30);
Send_Word(" g\n");
LCD1602_write_com(0x80 0x40);
LCD1602_write_data(Weight_Shiwu/1000 0X30);
LCD1602_write_data(Weight_Shiwu%1000/100 0X30);
LCD1602_write_data(Weight_Shiwu%100/10 0X30);
LCD1602_write_data(Weight_Shiwu%10 0X30);
LCD1602_write_word(" g");
}
}
}
评论