单片机设计_智能蓝牙电子秤(51单片机、HX711AD)

想要更多项目私wo!!!

一、电路设计

       智能蓝牙电子称由51单片机、HX711AD称重模块、HC-05蓝牙模块、LCD1602等电路组成硬件部分,然后上传至APP。

二、运行结果

单片机设计_智能蓝牙电子秤(51单片机、HX711AD)_第1张图片

三、部分代码

#include "main.h"
#include "HX711.h"
#include "uart.h"
#include "LCD1602.h"
#include 
#define uchar unsigned char  //ÎÞ·ûºÅ×Ö·ûÐÍ ºê¶¨Òå	±äÁ¿·¶Î§0~255
#define uint  unsigned int	 //ÎÞ·ûºÅÕûÐÍ ºê¶¨Òå	±äÁ¿·¶Î§0~65535

unsigned long HX711_Buffer = 0;
unsigned long Weight_Maopi = 0;
long Weight_Shiwu = 0;

unsigned char flag = 0;
bit Flag_ERROR = 0;
sbit beep= P1^7;

#define GapValue 405



//****************************************************
//Ö÷º¯Êý
//****************************************************
void main()
{
    Uart_Init();
  
	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)
		{
          
			

			LCD1602_write_com(0x80+0x40);
			LCD1602_write_word("ERROR ");
			beep=0;
		}		
		else
		{         
			beep=1;
            Send_ASCII(0x82);
            Send_ASCII(0x4);
            Send_ASCII(Weight_Shiwu >> 8);
            Send_ASCII(Weight_Shiwu);
			


			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");



		}

	

		
	}
}

你可能感兴趣的:(单片机,单片机,51单片机,嵌入式硬件)