#include <DHT22.h>
#define DHT22_PIN 7
#include <Wire.h>
DHT22 myDHT22(DHT22_PIN);
int Relay= 8 ;
int button =9;
void setup(void)
{
pinMode(button, INPUT);
pinMode(DHT22_PIN,INPUT );
pinMode(Relay, OUTPUT);
digitalWrite(button, HIGH);
if(Relay, HIGH);
Serial.begin(9600);//輸出視窗
Serial.println("DHT22 Library Demo");
}
void loop(void)
{
DHT22_ERROR_t errorCode;
errorCode = myDHT22.readData();
switch(errorCode)
{
case DHT_ERROR_NONE:
Serial.print("Got Data ");
Serial.print(myDHT22.getTemperatureC());
Serial.print("C ");//
Serial.print(myDHT22.getHumidity());
Serial.println("%");
}
digitalWrite(button==HIGH);
{
if(Relay, LOW);
}
digitalWrite(Relay, LOW);
for(int Relay=0; Relay<8; Relay ++)
delay(200);
}
請問哪裡有錯,請各位大大講解 |