这是我做的无线WIFI除尘系统的程序
51单片机主程序源程序如下:
- #include "lcd1602.h"
- #include "reg52.h"
- #include "intrins.h"
- #include "stdio.h"
- #include "delay.h"
- #include "key.h"
- #include "DJ.h"
- sbit JIASHI = P3^7;
- sbit led_lv = P1^6;
- sbit led_red = P1^5;
- extern void ReadHumidityTemperature(void);
- extern unsigned char data byHumidityValue,byTemperatureValue;
- extern uchar flag_zheng,flag_fan,flag_left,flag_right,flag_jia,flag_jian,flag_stop,flag_start,flag_jiashiqi,speed;//电机使用变量和标志位
- unsigned char data dis1[16] = {"RH: TEMP: C"};
- uchar down_data=75,up_data=80;
- uint DAT = 0;
- uchar num=0;
- uchar count=0;//电机使用变量
- void tmod_init()
- {
- TMOD = 0X11;
- TH1 = (65536-100)/256;
- TL1 = (65536-100)%256;
- TH0 = (65536-100)/256;
- TL0 = (65536-100)%256;
- EA = 1;
- ET1 = 1;
- TR1 = 1;
- ET0 = 1;
- TR0 = 1;
- }
- void Delay1000ms() //@12.000MHz
- {
- unsigned char i, j, k;
- i = 46;
- j = 153;
- k = 245;
- do
- {
- do
- {
- while (--k);
- } while (--j);
- } while (--i);
- }
- void adjust()
- {
-
- if(byHumidityValue<down_data) //灯和加湿器都是低电平有效
- {
- JIASHI = 0; //打开
- led_red = 0; //打开
- led_lv = 1;
- }
- else if(byHumidityValue>up_data)
- {
- JIASHI = 1;
- led_lv = 1;
- led_red = 0;
- }
- else if((byHumidityValue>=down_data)&&(byHumidityValue<=up_data))
- {
- led_lv = 0;
- led_red = 1;
- }
- else if(flag_jiashiqi==1) JIASHI = 0;
- else if(flag_jiashiqi==0) JIASHI = 1;
- }
- void main()
- {
- float dat=0;
- lcd_init();
- tmod_init();
- dis1[14]=0xDF;
- while(1)
- {
- ReadHumidityTemperature();
- LCD_Write_String(0,0,dis1);
- adjust();
- Delay1000ms();
- }
- }
- void t0_interrupt() interrupt 1
- {
- TH0 = (65536-10000)/256;
- TL0 = (65536-10000)%256;
- keyscan();
- }
- void t1_interrupt() interrupt 3
- {
- TH1 = (65536-100)/256;
- TL1 = (65536-100)%256;
-
- if(flag_zheng==1)//ZHENG
- {
- IN2=0;
- IN4=0;
- if(count==speed) {IN1=1;IN3=1;}
- if(count==100) {count=0;IN1=0;IN3=0;}
- }
- else if(flag_fan==1)//FAN
- {
- //flag_zheng=0;
- IN1=0;
- IN3=0;
- if(count==speed) {IN2=1;IN4=1;}
- if(count==100) {count=0;IN2=0;IN4=0;}
- }
-
- else if(flag_stop == 1)//TING
- {
- IN1=0;
- IN2=0;
- IN3=0;
- IN4=0;
- }
-
- else if(flag_left == 1)//ZUO ZHUAN
- {
-
- IN2=0; IN4=0;
- if(speed>=70) speed = 60;
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
WiFi除尘.zip
(84.47 KB, 下载次数: 9)
|