this week aimed to Design and program a smart device that perform a certain function or solve a problem: program Arduino UNO to read signals from multiple input components (Sensor, Switch, or variable resistor) to control multiple action components (Motor, Buzzer, LED...etc) using Arduino C (Text Code) so I wanted to design my graduation project circuit.
Software:
Arduino
Components:
breadboard
Arduino
LCD
LDR sensor
DHT.11 sensor
buzzer
lamp
relay
Adapter 9V
I wanted to design my project circuit so connect with each other then code on arduino it and connect Arduino with laptop and adapter
as shown in videos.
1-Assembly steps:
I connect LCD screen and code it on Arduino and download libraries of LCD.h and Liquidcrystal and DHT.11 and set the code...when the temperature less than 30 write we don't need to go when it grater than 30 write we have to go... then connect buzzer with them so when temperature less than 30 the buzzer will tone and write on LCD we don't need to go.. then I used relay with lamb and LDR sensor when it dark lamb will open.
buzzer = 13
LDR= 6
lamp = 8
DHT=2
LCD= A4 and A5
2-code
#include <DHT.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
float t ;
float h ;
int buzzer = 13 ;
int LDR = 6;
int lamp = 8;
void setup() {
pinMode(lamp, OUTPUT);
Serial.begin(9600);
Serial.println(F("DHTxx test!"));
pinMode(buzzer, OUTPUT);
lcd.init(); // initialize the lcd
lcd.backlight();
dht.begin();
lcd.clear();
//lcd.print("Humidity & temp");
//lcd.setCursor(0,1);
//delay(3000);
}
void loop()
{
h = dht.readHumidity();
t = dht.readTemperature();
if ( t <= 30 )
{
digitalWrite(buzzer,HIGH);
delay(5000);
digitalWrite(buzzer,LOW);
lcd.clear();
lcd.print("you dont need to go ");
lcd.setCursor(0, 1);
lcd.print("temp is = ");
lcd.print(t);
}
else
{
lcd.clear();
lcd.print("we have to go ");
lcd.setCursor(0, 1);
lcd.print("temp is = ");
lcd.print(t);
delay(5000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Temp");
lcd.print(t);
lcd.print("°C ");
lcd.setCursor(0, 1);
lcd.print("Humidity");
lcd.setCursor(9, 1);
lcd.print(h);
delay(5000);
}
if (digitalRead(LDR) == HIGH) {
digitalWrite(lamp, HIGH);
}
else {
digitalWrite(lamp, LOW);
}
}
code sequence:
include "LiquidCrystal_I2C.h"
Next set the address, number of column and number of rows using the function "LiquidCrystal_I2C lcd(). The address is 0x27 (discovered using the I2C Scanner Code). Number of columns is 16 and number of rows is 2. After this, we can call the display using "lcd". Next code the setup part. First initialize the display using the function " lcd.init();"
I downloaded the libraries of LCD and LIquidctystal and DHT and copied in libraries of Arduino then code it like video and set this phrase "you don't have to go" when temp below 30 degree... and make the lamp open when LDR sense dark...
tinker cad Wiring description :
By using tinker cad to simulate the idea that in my mind :
1- couldn't find DHT11 Sensor in tinker cad so replace it to temperature sensor from tinkercad as it's doing the same purpose
2- couldn't find the same model from LCD and used LCD16x2 that was provided on tinkercad
so wire lamb with relay module and power supply with Arduino and buzzer and DHT and LDR...
3-prepared all components and start wiring as shown in screenshots and wrote the text code and simulated it
I didn't know how I code LCD screen because the library can't download like video so I asked my friend and sent me link to download libraries and downloaded and copied files to library of program and open it on arduino to be defined..
1-after finishing from coding of LCD on Arduino i found the reads is
humidity & temp only and didn't give any reads for them so I connect with my friend nourhan and she helped me .
2- when I connect buzzer with components it wasn't give any voice so I discovered that I connect it negative with arduino and positive with ground...
Title of Media
Title of Media
Title of Media