当前位置:   article > 正文

121-基于stm32单片机出租车计价器收费系统Proteus仿真+程序源码_基于stm32单片机的出租车计价器

基于stm32单片机的出租车计价器

一:功能介绍

1、采用stm32单片机+LCD1602+DHT11温湿度传感器+L298N驱动+按键+电机,制作一个单片机出租车计价器收费系统;

2、通过按键进行设置开始计费和计费清零,计费采用起步价+(公里数-起步公里)*单价

3、按下开始按键,L298N驱动电机转动,模拟出租车启动,计费系统开始计费,

4、LCD1602显示出租车的温湿度、行驶里程和计费总价;

二:仿真演示视频+程序简要讲解:(程序有中文注释,新手容易看懂)

121-基于stm32单片机出租车计价器收费系统Proteus仿真+程序源码+讲解视频

三:设计软件介绍

本设计使用C语言编程设计,程序代码采用keil5编写,程序有中文注释,新手容易看懂,仿真采用Proteus软件进行仿真演示视频使用的是Proteus8.9版本;资料包里有相关软件包,可自行下载安装。

四:程序打开方法

特别注意:下载资料包以后一定要先解压!(建议解压到桌面上,文件路径太深会导致程序打开异常),解压后再用keil5打开。

c876228e3cc89e15336b3503eccad72b.png

f3f07d70b42339c38b51236a29d72c6b.png

  1. 程序部分展示,有中文注释,新手容易看懂
  2. void GPIO_Configuration(void)
  3. {
  4. GPIO_InitTypeDef GPIO_InitStructure;
  5. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
  6. //LCD1602 管脚
  7. 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;
  8. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  9. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  10. GPIO_Init(GPIOA, &GPIO_InitStructure);
  11. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 |GPIO_Pin_6|GPIO_Pin_5;
  12. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  13. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  14. GPIO_Init(GPIOA, &GPIO_InitStructure);
  15. }
  16. int main(void)
  17. {
  18. char buf=0,n=0;//车辆状态
  19. int num=0,zongjia=0,danjia=3;//行驶里程和总价和单价
  20. DHT11_Data_TypeDef DHT11_Data;
  21. RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
  22. /* 配置SysTick 为1us中断一次 */
  23. SysTick_Init();
  24. LED_GPIO_Config();
  25. motor_init(); GPIO_Configuration();
  26. Init1602();
  27. //NVIC_Configuration();
  28. TIM2_Configuration();
  29. UltrasonicWave_Configuration();
  30. // USART_Config();//初始化串口1
  31. NVIC_Configuration();
  32. /*初始化DTT11的引脚*/
  33. DHT11_Init();
  34. Key_GPIO_Config();
  35. WrByte1602(0,1,'T'); //符号显示
  36. WrByte1602(0,2,'=');
  37. WrByte1602(0,7,'H');
  38. WrByte1602(0,8,'=');
  39. WrByte1602(1,1,'K');
  40. WrByte1602(1,2,'M');
  41. WrByte1602(1,3,'=');
  42. WrByte1602(1,7,'k');
  43. WrByte1602(1,8,'m');
  44. WrByte1602(1,10,'Z');
  45. WrByte1602(1,11,'J');
  46. WrByte1602(1,12,'=');
  47. GPIO_SetBits(MOTOR_GPIO,Motor_Pin_13);
  48. GPIO_SetBits(MOTOR_GPIO,Motor_Pin_14);
  49. while(1)
  50. {
  51. //调用DHT11_Read_TempAndHumidity读取温湿度,若成功则输出该信息
  52. if( DHT11_Read_TempAndHumidity ( & DHT11_Data ) == SUCCESS)
  53. {
  54. WrByte1602(0,3,AsciiCode[DHT11_Data.temp_int%1000/100]);//温度
  55. WrByte1602(0,4,AsciiCode[DHT11_Data.temp_int%100/10]);
  56. WrByte1602(0,5,AsciiCode[DHT11_Data.temp_int%10]);
  57. WrByte1602(0,9,AsciiCode[DHT11_Data.humi_int%1000/100]);//湿度
  58. WrByte1602(0,10,AsciiCode[DHT11_Data.humi_int%100/10]);
  59. WrByte1602(0,11,AsciiCode[DHT11_Data.humi_int%10]);
  60. }
  61. if( key1 == 1 )//启动或者停止
  62. {
  63. buf++;while(key1!=0);
  64. if(buf>1) buf=0;
  65. }
  66. if(buf==1)//启动开始计价
  67. {
  68. GPIO_SetBits(MOTOR_GPIO,Motor_Pin_13);//开启电机
  69. GPIO_ResetBits(MOTOR_GPIO,Motor_Pin_14);
  70. n++;
  71. if(n>8)
  72. {
  73. num++;
  74. n=0;
  75. }
  76. }
  77. if(num<1) zongjia=0;
  78. if(num<3&&num>0)//3公里内起步价15元
  79. {
  80. zongjia=15;
  81. }
  82. if(num>3)
  83. {
  84. zongjia=15+(num-3)*danjia;//总价=起步价+单价*(公里数-起步3公里)
  85. }
  86. if(buf==0)//按下停止
  87. {
  88. GPIO_ResetBits(MOTOR_GPIO,Motor_Pin_13);//开启电机
  89. GPIO_ResetBits(MOTOR_GPIO,Motor_Pin_14);
  90. }
  91. if(key2==1) zongjia=num=0;//清零
  92. WrByte1602(1,4,AsciiCode[num/100]);//显示里程
  93. WrByte1602(1,5,AsciiCode[num%100/10]);
  94. WrByte1602(1,6,AsciiCode[num%10]);
  95. WrByte1602(1,13,AsciiCode[zongjia/100]);//显示总价
  96. WrByte1602(1,14,AsciiCode[zongjia%100/10]);
  97. WrByte1602(1,15,AsciiCode[zongjia%10]);
  98. }

:仿真文件(采用Proteus打开)

4d19d11190d95f0f5640e8267c6e6efa.png

3899e9243e1481c8c736ba7d218b0a20.png

35a872b4a266c1c6e5eab40cd451a99f.png

六:资料清单展示(文件中包含的相关资料)

bee337b08cc7977ec450427cee877436.png

百度云盘下载链接

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/385714?site
推荐阅读
相关标签
  

闽ICP备14008679号