液滴测速的源程序和仿真分享给大家
点滴测量系统
带液面检测 按键按下为液面抵达最低位置
单片机源程序如下:
- /*************** writer:shopping.w ******************/
- #include <reg52.h>
- #include <string.h>
- #include "time.h"
- #include "lcd1602.h"
- #include "INT.h"
- #define uchar unsigned char
- #define uint unsigned int
- sbit SPK= P2^4;
- sbit IN0=P3^2;
- void Delayxms(uint ms)
- {
- uchar i;
- while(ms--)
- {
- for(i=0;i<120;i++);
- }
- }
- void main()
- {
- Initialize_LCD();
- ShowString(0,0,"Speed: d/min ");
- ShowString(0,1,"State: ");
- Delayxms(500);
- Int0_Init(); //外部中断初始化
- Time0_Init(); //定时器初始化
- while(1)
- {
- if(IN0==0) //达到最低液面
- {
- SPK=0;
- Delayxms(300);
- SPK=1;
- Delayxms(300);
- ShowString(7,1,"Abnormal ");
-
- }
- else
- {
-
- ShowString(7,1,"Normal ");
- }
-
-
- Write_LCD_Command(0x80+6); //第一行0x8开头
- Write_LCD_Data(dd/1000+0x30);
- Write_LCD_Data(dd/100+0x30);
- Write_LCD_Data(dd%100/10+0x30);
- Write_LCD_Data(dd%100%10+0x30);
- /*
- Write_LCD_Command(0xc0+6); //第二行0xc0开头
- Write_LCD_Data(count/1000+0x30);
- Write_LCD_Data(count%1000/100+0x30);
- Write_LCD_Data(count%1000%100/10+0x30);
- Write_LCD_Data(count%1000%100%10+0x30);
- */
- if(dd>60)
- {
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
5-Protues仿真.rar
(45.35 KB, 下载次数: 149)
|