赞
踩
一:功能介绍
1、采用stm32单片机+LCD1602+DHT11温湿度传感器+L298N驱动+按键+电机,制作一个单片机出租车计价器收费系统;
2、通过按键进行设置开始计费和计费清零,计费采用起步价+(公里数-起步公里)*单价
3、按下开始按键,L298N驱动电机转动,模拟出租车启动,计费系统开始计费,
4、LCD1602显示出租车的温湿度、行驶里程和计费总价;
二:仿真演示视频+程序简要讲解:(程序有中文注释,新手容易看懂)
121-基于stm32单片机出租车计价器收费系统Proteus仿真+程序源码+讲解视频
三:设计软件介绍
本设计使用C语言编程设计,程序代码采用keil5编写,程序有中文注释,新手容易看懂,仿真采用Proteus软件进行仿真,演示视频使用的是Proteus8.9版本;资料包里有相关软件包,可自行下载安装。
四:程序打开方法
特别注意:下载资料包以后一定要先解压!!!(建议解压到桌面上,文件路径太深会导致程序打开异常),解压后再用keil5打开。
- 程序部分展示,有中文注释,新手容易看懂
- void GPIO_Configuration(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
-
-
- //LCD1602 管脚
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8| GPIO_Pin_9| GPIO_Pin_10| GPIO_Pin_11| GPIO_Pin_12| GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 |GPIO_Pin_6|GPIO_Pin_5;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
-
-
- }
- int main(void)
- {
- char buf=0,n=0;//车辆状态
- int num=0,zongjia=0,danjia=3;//行驶里程和总价和单价
- DHT11_Data_TypeDef DHT11_Data;
- RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
-
-
- /* 配置SysTick 为1us中断一次 */
- SysTick_Init();
- LED_GPIO_Config();
- motor_init(); GPIO_Configuration();
- Init1602();
- //NVIC_Configuration();
- TIM2_Configuration();
- UltrasonicWave_Configuration();
-
-
- // USART_Config();//初始化串口1
- NVIC_Configuration();
-
-
- /*初始化DTT11的引脚*/
- DHT11_Init();
-
-
- Key_GPIO_Config();
-
-
- WrByte1602(0,1,'T'); //符号显示
- WrByte1602(0,2,'=');
- WrByte1602(0,7,'H');
- WrByte1602(0,8,'=');
- WrByte1602(1,1,'K');
- WrByte1602(1,2,'M');
- WrByte1602(1,3,'=');
- WrByte1602(1,7,'k');
- WrByte1602(1,8,'m');
- WrByte1602(1,10,'Z');
- WrByte1602(1,11,'J');
- WrByte1602(1,12,'=');
- GPIO_SetBits(MOTOR_GPIO,Motor_Pin_13);
- GPIO_SetBits(MOTOR_GPIO,Motor_Pin_14);
- while(1)
- {
- //调用DHT11_Read_TempAndHumidity读取温湿度,若成功则输出该信息
- if( DHT11_Read_TempAndHumidity ( & DHT11_Data ) == SUCCESS)
- {
-
- WrByte1602(0,3,AsciiCode[DHT11_Data.temp_int%1000/100]);//温度
- WrByte1602(0,4,AsciiCode[DHT11_Data.temp_int%100/10]);
- WrByte1602(0,5,AsciiCode[DHT11_Data.temp_int%10]);
-
- WrByte1602(0,9,AsciiCode[DHT11_Data.humi_int%1000/100]);//湿度
- WrByte1602(0,10,AsciiCode[DHT11_Data.humi_int%100/10]);
- WrByte1602(0,11,AsciiCode[DHT11_Data.humi_int%10]);
- }
-
-
- if( key1 == 1 )//启动或者停止
- {
- buf++;while(key1!=0);
- if(buf>1) buf=0;
- }
- if(buf==1)//启动开始计价
- {
- GPIO_SetBits(MOTOR_GPIO,Motor_Pin_13);//开启电机
- GPIO_ResetBits(MOTOR_GPIO,Motor_Pin_14);
- n++;
- if(n>8)
- {
- num++;
- n=0;
- }
- }
- if(num<1) zongjia=0;
- if(num<3&&num>0)//3公里内起步价15元
- {
- zongjia=15;
- }
- if(num>3)
- {
- zongjia=15+(num-3)*danjia;//总价=起步价+单价*(公里数-起步3公里)
- }
- if(buf==0)//按下停止
- {
- GPIO_ResetBits(MOTOR_GPIO,Motor_Pin_13);//开启电机
- GPIO_ResetBits(MOTOR_GPIO,Motor_Pin_14);
- }
- if(key2==1) zongjia=num=0;//清零
-
- WrByte1602(1,4,AsciiCode[num/100]);//显示里程
- WrByte1602(1,5,AsciiCode[num%100/10]);
- WrByte1602(1,6,AsciiCode[num%10]);
- WrByte1602(1,13,AsciiCode[zongjia/100]);//显示总价
- WrByte1602(1,14,AsciiCode[zongjia%100/10]);
- WrByte1602(1,15,AsciiCode[zongjia%10]);
-
- }

五:仿真文件(采用Proteus打开)
六:资料清单展示(文件中包含的相关资料)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。