简单的出租车计价器
出租车金额随着里程数加五
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
STM32单片机源程序如下:
- #include "stm32f10x.h"
- #include <stdio.h>
- #include "lcd.h"
- #include "delay.h"
- #include "motor.h"
- #include "bsp_led.h"
- #include "bsp_exti.h"
- unsigned int i,j;
- unsigned char temp_table[16];
- unsigned char temp_set_table[16];
- unsigned int total = 0;
- unsigned int MotorFlag = 0;
- int main(void)
- {
- LED_Init();
- LED(OFF);
-
- L298_GPIO();
- STOP();
-
- Key_Init();
-
- GPIO_InitStructReadtempCmd();
- lcd_system_reset();
-
- while(1)
- {
-
-
- if(MotorFlag)
- {
- total = total + 5;
- sprintf(temp_table,"price: %d ",5);
- sprintf(temp_set_table,"total: %d ",total);
-
- for(i=0;i<16;i++)
- lcd_char_write(i,0,temp_table[i]);
- for(j=0;j<16;j++)
- lcd_char_write(j,1,temp_set_table[j]);
- }
- else
- {
- total = 0;
- lcd_system_reset();
-
- }
- delay_ms(500);
- }
- }
复制代码
所有资料51hei提供下载:
MyProject.7z
(346.66 KB, 下载次数: 69)
|