加入星計(jì)劃,您可以享受以下權(quán)益:

  • 創(chuàng)作內(nèi)容快速變現(xiàn)
  • 行業(yè)影響力擴(kuò)散
  • 作品版權(quán)保護(hù)
  • 300W+ 專業(yè)用戶
  • 1.5W+ 優(yōu)質(zhì)創(chuàng)作者
  • 5000+ 長(zhǎng)期合作伙伴
立即加入

基于STM32的簡(jiǎn)易電子秤仿真設(shè)計(jì)( proteus仿真+程序)

08/06 09:17
1699
服務(wù)支持:
技術(shù)交流群

完成交易后在“購(gòu)買成功”頁(yè)面掃碼入群,即可與技術(shù)大咖們分享疑惑和經(jīng)驗(yàn)、收獲成長(zhǎng)和認(rèn)同、領(lǐng)取優(yōu)惠和紅包等。

虛擬商品不可退

當(dāng)前內(nèi)容為數(shù)字版權(quán)作品,購(gòu)買后不支持退換且無(wú)法轉(zhuǎn)移使用。

加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論
放大
實(shí)物圖
相關(guān)方案
  • 方案介紹
  • 相關(guān)文件
  • 推薦器件
  • 相關(guān)推薦
  • 電子產(chǎn)業(yè)圖譜
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

仿真圖proteus 8.9

程序編譯器:keil 5

編程語(yǔ)言:C語(yǔ)言

設(shè)計(jì)編號(hào):C0055

主要功能:

基于STM32的簡(jiǎn)易電子秤仿真,讀取壓力傳感器數(shù)值,帶總價(jià)自動(dòng)計(jì)算,使用LCD1602顯示。

注意:矩陣鍵盤不起作用,因?yàn)闆]有時(shí)間編程,其它功能正常。

Proteus仿真

img

程序

img

main函數(shù):

主要顯示當(dāng)前的壓力傳感器數(shù)值。

#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "lcd1602.h"
#include "adc0804.h"

int main(void)
{
		u8 adcx = 0;
		u8 totalll = 0;	
		uint8_t adcxxx[4] = {0, 0, 0, 0};
		uint8_t total[5] = {0, 0, 0, 0, 0};		
		LCD_init();
		ADC_init();	
		lcd_delay_ms(1000);
		LCD_write_string(0,1," WGT*PRICE=TOTAL");		
		LCD_write_string(6, 0, "*");
		LCD_write_string(10, 0, "=");
		while(1)
		{
				adcx = read_adc0804();	
				adcxxx[0] = (adcx % 100 / 10) + 0x30;
				adcxxx[1] = 46;
				adcxxx[2] = (adcx % 10) + 0x30;
				adcxxx[3] = (((adcx % 100 / 10) * (adcx % 10)) + (adcx % 10)) % 10 + 0x30;	
				totalll = ((adcx % 100 / 10) * 10 + (adcx % 10)) * 2;
				total[0] = (totalll / 100) + 0x30;
				total[1] = (totalll % 100 / 10) + 0x30;
				total[2] = 46;
				total[3] = (totalll % 10) + 0x30;
				LCD_write_string(0, 0, (char*)adcxxx);
				LCD_write_string(11, 0, (char*)total);	
				LCD_write_string(8, 0, "2");	
				lcd_delay_ms(1000);			
		}
}



LCD1602顯示驅(qū)動(dòng)

#include "lcd1602.h"
#include "delay.h"
                             
#define DELAY_2N     0

void lcd_delay_us(unsigned int t)
{
	unsigned int i, j;
	
	for(i = 10; i > 0; i--)
		for(j = t; j > 0; j--);
}

void lcd_delay_ms(unsigned int t)
{	
	unsigned int i;
	
	for(i = t; i > 0; i--)
		lcd_delay_us(10);
}

//==================================================
void LCD_init(void)
{
    /*********************液晶使用的I/O口初始化**************************/ 
		GPIO_InitTypeDef GPIO_InitStructure;
	
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
  
    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_1 | GPIO_Pin_2| GPIO_Pin_0| GPIO_Pin_3
																	| GPIO_Pin_4| GPIO_Pin_5| GPIO_Pin_6| GPIO_Pin_7
																	| GPIO_Pin_8| GPIO_Pin_9| GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
	
    LCD_RW(0);			//讀寫位直接低電平,只寫不讀

    /*********************液晶初始化**************************/        
    lcd_delay_us(340); 
		LCD_RS(0);
   
    LCD_write_cmd(0x38);          // 8bit顯示模式,2行,5x7字體
    lcd_delay_ms(4);  
    LCD_write_cmd(0x08);         // 顯示關(guān)閉 
    lcd_delay_ms(4); 
    LCD_write_cmd(0x01);         // 顯示清屏 
    lcd_delay_ms(4); 
    LCD_write_cmd(0x06);         // 顯示光標(biāo)移動(dòng)設(shè)置 
    lcd_delay_ms(4);
    LCD_write_cmd(0x0c);         // 顯示開,光標(biāo)開,光標(biāo)閃爍
    lcd_delay_ms(4);
		LCD_write_cmd(0x01);         //清屏
		lcd_delay_ms(4);
}
/*--------------------------------------------------
函數(shù)說(shuō)明:寫命令到液晶


---------------------------------------------------*/
void LCD_write_cmd(unsigned char cmd)
{
    LCD_RS(0);
    LCD_Write_byte(cmd);
    lcd_delay_us(340);
}
/*--------------------------------------------------
函數(shù)說(shuō)明:寫數(shù)據(jù)到液晶


---------------------------------------------------*/
void LCD_write_data(unsigned char w_data)
{
    LCD_RS(1);
    LCD_Write_byte(w_data);
    lcd_delay_us(340);
}
/*--------------------------------------------------
函數(shù)說(shuō)明:寫4bit到液晶
--------------------------------------------------*/
void LCD_Write_byte(unsigned char num)
{  
		if (num&0x01)
				data0(1);
		else
				data0(0);

		if (num&0x02)
				data1(1);
		else
				data1(0);

		if (num&0x04)
				data2(1);
		else
				data2(0);

		if (num&0x08)
				data3(1);
		else
				data3(0);

		if (num&0x10)
				data4(1);
		else
				data4(0);

		if (num&0x20)
				data5(1);
		else
				data5(0);

		if (num&0x40)
				data6(1);
		else
				data6(0);
		
		if (num&0x80)
				data7(1);
		else
				data7(0);
		lcd_delay_us(340);
    LCD_EN(1);
    lcd_delay_us(340);
    LCD_EN(0); 
    lcd_delay_us(340);
}

/*----------------------------------------------------
LCD_set_xy        : 設(shè)置LCD顯示的起始位置
輸入?yún)?shù):x、y    : 顯示字符串的位置,X:0-15,Y:0-1                
-----------------------------------------------------*/
void LCD_set_xy( unsigned char x, unsigned char y )
{
    unsigned char address = 0;
    if (y==0) 
    {
        address=0x80+x;
    }
    else 
    {
        address=0xc0+x;
    }
//		y ? (address=0xc0+x): (address=0x80+x) ;
    LCD_write_cmd(address);
}
/*---------------------------------------------------
LCD_write_string  : 英文字符串顯示函數(shù)
輸入?yún)?shù):*s      :英文字符串指針;
          X、Y    : 顯示字符串的位置                
---------------------------------------------------*/
void LCD_write_string(unsigned char X,unsigned char Y, char *s)
{
    LCD_set_xy(X,Y);   
    while (*s) 
    {
        LCD_write_data(*s);
        s++;
    }
}

//=======================================================
void LCD_wstring(unsigned char X,unsigned char *s)
{
    LCD_write_cmd(X);   
    while (*s) 
    {
        LCD_write_data(*s);
        s++;
    }
}


資料設(shè)計(jì)

下載

image-20220824012413186

  • 設(shè)計(jì)資料獲取聯(lián)系方式.doc

推薦器件

更多器件
器件型號(hào) 數(shù)量 器件廠商 器件描述 數(shù)據(jù)手冊(cè) ECAD模型 風(fēng)險(xiǎn)等級(jí) 參考價(jià)格 更多信息
PIC24EP512GU810-I/PT 1 Microchip Technology Inc 16-BIT, FLASH, 60 MHz, MICROCONTROLLER, PQFP100, 12 X 12 MM, 1 MM HEIGHT, LEAD FREE, PLASTIC, TQFP-100

ECAD模型

下載ECAD模型
$10.44 查看
STM32F429ZIT6 1 STMicroelectronics High-performance advanced line, Arm Cortex-M4 core with DSP and FPU, 2 Mbytes of Flash memory, 180 MHz CPU, ART Accelerator, Chrom-ARTAccelerator, FMC with SDRAM, TFT

ECAD模型

下載ECAD模型
$24.77 查看
PIC32MX795F512L-80V/PT 1 Microchip Technology Inc 32-BIT, FLASH, 80 MHz, RISC MICROCONTROLLER, PQFP100, 12 X 12 MM, 1 MM HEIGHT, LEAD FREE, PLASTIC, TQFP-100

ECAD模型

下載ECAD模型
$12 查看

相關(guān)推薦

電子產(chǎn)業(yè)圖譜