Ideation
I will turn on/ off the LED and show the temp on the screen with GUI.
I used
1- Breadboard
2- Arduino UNO
3- Jumpers
4- LED
5- DH11 Humidity and Temp sensor
6- resistance
I connected the DH11 :
1-GND to GND
2- vcc to 5v
3- Data to pin 4.
LED
1-(+ve) to pin 2
2-(-ve ) to resistance
Push button
1- to resistance
2- to GND
the Arduino code
#include "DHT.h"
#define DHTPIN 4
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
int LED = 2;
int state =1;
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
dht.begin();
pinMode (LED, OUTPUT);
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F(" Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("C "));
Serial.print(f);
Serial.print(F("F Heat index: "));
Serial.print(hic);
Serial.print(F("C "));
Serial.print(hif);
Serial.println(F("F"));
if(Serial.available())
{
char x = Serial.read ();
if ( x == 'a'){
if (state ==0) {
state = 1;
digitalWrite (LED, HIGH);
}
else if (state == 1) {
state == 0;
digitalWrite (LED, LOW);
}
}
}
}
When I got stuck , I asked Haneen
the wireless communication by using bluetooth