#İnclude <LiquidCrystal_I2C.h>
Liquidcrystal_ı2C LCD(0x27, 16, 2);
Byte degree_symbol[8] =
{
0B00111,
0B00101,
0B00111,
0B00000,
0B00000,
0B00000,
0B00000,
0B00000.
};
İnt gate=11;
Volatile unsigned long duration=0;
Unsigned char i[5];
Unsigned int j[40];
Unsigned char value=0;
Unsigned answer=0;
İnt z=0;
İnt b=1;
Void setup()
{
lcd.init();
lcd.init();
lcd.backlight();
LCD. Print("temp = ");
LCD. Setcursor(0, 1);
LCD. Print("humidity = ");
LCD. Createchar(1, degree_symbol);
LCD. Setcursor(9, 0);
LCD. Write(1);
LCD. Print("c");
LCD. Setcursor(13, 1);
LCD. Print("%");
}
Void loop()
{
Delay(1000);
While(1)
{
Delay(1000);
Pinmode(gate, output);
Digitalwrite(gate, low);
Delay(20);
Digitalwrite(gate, hıgh);
Pinmode(gate, ınput_pullup);
Duration=pulseın(gate, low);
İf(duration <= 84 && duration >= 72)
{
While(1)
{
Duration=pulseın(gate, hıgh);
İf(duration <= 26 && duration >= 20){
Value=0;}
Else if(duration <= 74 && duration >= 65){
Value=1;}
Else if(z==40){
Break;}
İ[z/8]|=value<<(7- (z%8));
J[z]=value;
Z++;
}
}
Answer=i[0]+i[1]+i[2]+i[3];
İf(answer==i[4] && answer!=0)
{
LCD. Setcursor(7, 0);
LCD. Print(i[2]);
LCD. Setcursor(11, 1);
LCD. Print(i[0]);
}
Z=0;
İ[0]=i[1]=i[2]=i[3]=i[4]=0;
}
}