Home > other >  Smoke alarm temperature humidity sensor only bright screen does not display the great god give direc
Smoke alarm temperature humidity sensor only bright screen does not display the great god give direc

Time:09-23

[mw_shl_code=bash, true] # include
,11,5,4,3,2 LiquidCrystal LCD (12);
int temp;
Int humi.
Int tol.
Int j;
Int H=50;
Int T=25;
Int B=1;
Int flag=0;
Int led=7;
Int LED=9;
Int BU=2;
Int BUTTON=3;
Int FMQ=13;
Int FMQ=10;
Unsigned int loopCnt;
Int CRH [40]={0};
Unsigned long time;
# define pin 8
Void setup ()
{pinMode (FMQ, the OUTPUT); PinMode (FMQ, the OUTPUT); PinMode (LED, the OUTPUT); PinMode (led, the OUTPUT); Serial.begin(9600);
}
Void loop ()
{HH (); TT (); KeyScan (); BGN: delay (200); PinMode (pin, the OUTPUT); DigitalWrite (pin, LOW); Delay (20); DigitalWrite (pin, HIGH); DelayMicroseconds (40); DigitalWrite (pin, LOW); PinMode (pin, INPUT); LoopCnt=10000; While (digitalRead (pin).=HIGH) {if (loopCnt --==0) {Serial. Println (" HIGH "); Goto BGN; }} loopCnt=30000; While (digitalRead (pin).=LOW) {if (loopCnt --==0) {Serial. Println (" LOW "); Goto BGN; } } for(int i=0; i<40; {i++) while (digitalRead (pin)==LOW) {} time=micros (); While (digitalRead (pin)==HIGH) {} the if (micros () - time & gt; 50) {CRH=1; } else {CRH=0; }} humi=CRH CRH [0] * 128 + [1] * 64 + CRH [2] * 32 + CRH [3] * 16 + CRH [4] * 8 + CRH [5] * 4 + CRH [6] * 2 + CRH [7]. Temp=CRH [16] * 128 + CRH [17] * 64 + CRH [18] * 32 + CRH [19] * 16 + CRH [20] * 8 + CRH [21] * 4 + CRH [22] * 2 + CRH [23].
Tol=CRH [32] * 128 + CRH [33] * 64 + CRH [34] * 32 + CRH [35] * 16 + CRH [36] * 8 + CRH [37] * 4 + CRH [38] * 2 + CRH [39]. Serial. Print (" temp: "); Serial. Println (temp); Serial. Print (" humi: "); Serial. Println (humi); Serial. Print (" tol: "); Serial. Println (tol);

If (temp> T)
{digitalWrite (LED, HIGH); DigitalWrite (FMQ, LOW); } else {
DigitalWrite (LED, LOW);
DigitalWrite (FMQ, HIGH);
}
If (humi> H)
{digitalWrite (led, HIGH); DigitalWrite (FMQ, LOW); } else {
DigitalWrite (led, LOW);
DigitalWrite (FMQ, HIGH);
}

int val; Val=analogRead (0); Serial. Print (smo ":"); Serial. Println (val, DEC); Delay (100);
If (flag==0)
{LCD. The begin (16, 2); LCD. SetCursor (0, 0); LCD. Print (TEMP: "C"); LCD. SetCursor (9, 0); LCD. Print (SMO ":"); LCD. SetCursor (0, 1); LCD. Print (" HUMI: % "); LCD. SetCursor (9, 1);//LCD. Print (" BEP: "); LCD. SetCursor (5, 0); LCD. Print (temp); LCD. SetCursor (5, 1); LCD. Print (humi); LCD. SetCursor (13, 0); LCD. Print (val, DEC);
}
If (flag==1)
{LCD. The begin (16, 2); LCD. Print (" ALARM TEMP: "); LCD. SetCursor (11, 0); LCD. Print (T);

}
If (flag==2)
{LCD. The begin (16, 2); LCD. Print (" ALARM HUMI: "); LCD. SetCursor (12, 0); LCD. Print (H);

}
}
Void keyScan ()
{if (analogRead (BUTTON) & gt; 600) {delay (20); If (analogRead (BUTTON) & gt; 600) {flag++; If (flag>=3) flag=0; While (analogRead (BUTTON) & gt; 600); }}
}
Void HH ()
{if (analogRead (B) & gt; 600) {delay (20); If (analogRead (B) & gt; 600) {H++; If (H> H==61) 40; While (analogRead (B) & gt; 600); }}
}
Void (TT)
{if (analogRead (BU) & gt; 600) {delay (20); If (analogRead (BU) & gt; 600) {T++; If (T>=31) T=20; While (analogRead (BU) & gt; 600); }}
}

CodePudding user response:

No one reply
  • Related