實踐大學聯網感測實作
開發環境This project is maintained by yazelin
積沙成塔 集腋成裘
// including the library
#include<dht11.h>
// initial
void setup(){
// Serial Baudrate
Serial.begin(115200);
}
// including the library
#include<dht11.h>
// Module variable
dht11 DhtSensor;
int PsSensor;
// main loop
void loop(){
// Read sensor data
DhtSensor.read(A0);
PsSensor = analogRead(A1);
// Show value
Serial.print("Humidity : ");
Serial.println(DhtSensor.humidity);
Serial.print("Temperature : ");
Serial.println(DhtSensor.temperature);
Serial.print("Pressure : ");
Serial.println(PsSensor);
delay(1000);
}
// initial
void setup(){
// Serial Baudrate
Serial.begin(115200);
// Setting I/O mode
pinMode(5 ,OUTPUT);
pinMode(6 ,OUTPUT);
pinMode(7 ,OUTPUT);
}
// main loop
void loop(){
// Read sensor data
DhtSensor.read(A0);
PsSensor = analogRead(A1);
// Show value
Serial.print("Humidity : ");
Serial.println(DhtSensor.humidity);
Serial.print("Temperature : ");
Serial.println(DhtSensor.temperature);
Serial.print("Pressure : ");
Serial.println(PsSensor);
// Test output
digitalWrite(5 ,HIGH);
digitalWrite(6 ,HIGH);
digitalWrite(7 ,HIGH);
}
// initial
void setup(){
// Serial Baudrate
Serial.begin(115200);
// Setting I/O mode
pinMode(5 ,OUTPUT);
pinMode(6 ,OUTPUT);
pinMode(7 ,OUTPUT);
digitalWrite(5 ,LOW);
digitalWrite(6 ,LOW);
digitalWrite(7 ,LOW);
}
// main loop
void loop(){
// Read sensor data
DhtSensor.read(A0);
PsSensor = analogRead(A1);
// Show value
Serial.print("Humidity : ");
Serial.println(DhtSensor.humidity);
Serial.print("Temperature : ");
Serial.println(DhtSensor.temperature);
Serial.print("Pressure : ");
Serial.println(PsSensor);
// Test output
if(DhtSensor.humidity <= 30){
digitalWrite(7 ,HIGH);
}else{
digitalWrite(7 ,LOW);
}
if(DhtSensor.temperature <= 25){
digitalWrite(6 ,HIGH);
}else{
digitalWrite(6 ,LOW);
}
if(PsSensor >= 10){
digitalWrite(5 ,HIGH);
}else{
digitalWrite(5 ,LOW);
}
delay(1000);
}
將課堂做完的成果錄影後貼至FB社團內