SlideShare a Scribd company logo
#include <dht11.h>
#define DHT11PIN 4
#include <Wire.h>
#include <LiquidCrystal_I2C.h>//includesthe LiquidCrystal Library
LiquidCrystal_I2Clcd(0x3F,16,2);
const inttrigPin= 9;
const intechoPin=10;
const intbuzzer= 11;
const intledPin=13;
longduration;
intdistance;
intSafedistance;
dht11 DHT11;
voidsetup() {
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
pinMode(buzzer,OUTPUT);
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
lcd.begin();
lcd.backlight();
lcd.blink_on() ;
}
voidloop() {
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
delayMicroseconds(10);
digitalWrite(trigPin,LOW);
duration= pulseIn(echoPin,HIGH);
distance=duration*0.034/2;
Safedistance =distance;
if (Safedistance <=10 ) {
digitalWrite(buzzer,HIGH);
digitalWrite(ledPin,HIGH);
}
else{
digitalWrite(buzzer,LOW);
digitalWrite(ledPin,LOW);
}
lcd.print("cm");//Printsstring"Distance"onthe LCD
lcd.setCursor(0,0);
lcd.print("Distance:");
lcd.print(distance);
lcd.print("cm");
Serial.print("Distance:");
Serial.println(distance);
intchk = DHT11.read(DHT11PIN);
lcd.setCursor(0,1);
lcd.print("Temperature:");
lcd.print((float)DHT11.temperature,2);
Serial.print("Temperature (C):");
Serial.println((float)DHT11.temperature,2);
delay(1000);
}
coding and wiring dht11 and ultrasonic hcsr04 arduino

More Related Content

What's hot

Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
BlackD10
 
Micro Assignment 2
Micro Assignment 2Micro Assignment 2
Micro Assignment 2
babak danyal
 
Fpga creating counter with external clock
Fpga   creating counter with external clockFpga   creating counter with external clock
Fpga creating counter with external clock
Politeknik Elektronika Negeri Surabaya
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
Politeknik Elektronika Negeri Surabaya
 
123
123123
گزارش کار
گزارش کارگزارش کار
گزارش کار
Omid Karimpour
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console Interface
David Young
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
Giovanni Bechis
 
Metal detecting robot sketch
Metal detecting robot sketchMetal detecting robot sketch
Metal detecting robot sketch
Akhil Unnikrishnan
 
[DSC] Introduction to Binary Exploitation
[DSC] Introduction to Binary Exploitation[DSC] Introduction to Binary Exploitation
[DSC] Introduction to Binary Exploitation
Florian Müller
 
Arduino and Robotics
Arduino and RoboticsArduino and Robotics
Arduino and Robotics
Mebin P M
 
The Simple Scheduler in Embedded System @ OSDC.TW 2014
The Simple Scheduler in Embedded System @ OSDC.TW 2014The Simple Scheduler in Embedded System @ OSDC.TW 2014
The Simple Scheduler in Embedded System @ OSDC.TW 2014
Jian-Hong Pan
 
ゆるふわコンピュータ (IPSJ-ONE2017)
ゆるふわコンピュータ (IPSJ-ONE2017)ゆるふわコンピュータ (IPSJ-ONE2017)
ゆるふわコンピュータ (IPSJ-ONE2017)
Shinya Takamaeda-Y
 
Using ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instrumentsUsing ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instruments
a_n0v
 
Direct analog
Direct analogDirect analog
Direct analog
srikanthsailu
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
DefconRussia
 
Pledge in OpenBSD
Pledge in OpenBSDPledge in OpenBSD
Pledge in OpenBSD
Giovanni Bechis
 
Lcd n PIC16F
Lcd n PIC16FLcd n PIC16F
Lcd n PIC16F
hairilfaiz86
 
REPORT
REPORTREPORT
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 

What's hot (20)

Codigo fuente
Codigo fuenteCodigo fuente
Codigo fuente
 
Micro Assignment 2
Micro Assignment 2Micro Assignment 2
Micro Assignment 2
 
Fpga creating counter with external clock
Fpga   creating counter with external clockFpga   creating counter with external clock
Fpga creating counter with external clock
 
Fpga creating counter with internal clock
Fpga   creating counter with internal clockFpga   creating counter with internal clock
Fpga creating counter with internal clock
 
123
123123
123
 
گزارش کار
گزارش کارگزارش کار
گزارش کار
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console Interface
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
 
Metal detecting robot sketch
Metal detecting robot sketchMetal detecting robot sketch
Metal detecting robot sketch
 
[DSC] Introduction to Binary Exploitation
[DSC] Introduction to Binary Exploitation[DSC] Introduction to Binary Exploitation
[DSC] Introduction to Binary Exploitation
 
Arduino and Robotics
Arduino and RoboticsArduino and Robotics
Arduino and Robotics
 
The Simple Scheduler in Embedded System @ OSDC.TW 2014
The Simple Scheduler in Embedded System @ OSDC.TW 2014The Simple Scheduler in Embedded System @ OSDC.TW 2014
The Simple Scheduler in Embedded System @ OSDC.TW 2014
 
ゆるふわコンピュータ (IPSJ-ONE2017)
ゆるふわコンピュータ (IPSJ-ONE2017)ゆるふわコンピュータ (IPSJ-ONE2017)
ゆるふわコンピュータ (IPSJ-ONE2017)
 
Using ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instrumentsUsing ARM Dev.Board in physical experimental instruments
Using ARM Dev.Board in physical experimental instruments
 
Direct analog
Direct analogDirect analog
Direct analog
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
 
Pledge in OpenBSD
Pledge in OpenBSDPledge in OpenBSD
Pledge in OpenBSD
 
Lcd n PIC16F
Lcd n PIC16FLcd n PIC16F
Lcd n PIC16F
 
REPORT
REPORTREPORT
REPORT
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 

Similar to coding and wiring dht11 and ultrasonic hcsr04 arduino

Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
SANTIAGO PABLO ALBERTO
 
Distance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino UnoDistance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino Uno
Aswin KP
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
Eueung Mulyana
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
SANTIAGO PABLO ALBERTO
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
hairilfaiz86
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
Svet Ivantchev
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
SIGMATAX1
 
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Irfan Qadoos
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
julioalexanderaguila
 
Magnetic door lock using arduino
Magnetic door lock using arduinoMagnetic door lock using arduino
Magnetic door lock using arduino
Sravanthi Sinha
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
footstatus
 
Uart
UartUart
Uart
cs1090211
 
code-nodemcu.docx
code-nodemcu.docxcode-nodemcu.docx
code-nodemcu.docx
LTinTun
 
Tdm to vo ip 2
Tdm to vo ip 2Tdm to vo ip 2
Tdm to vo ip 2
Abhiroop Mn
 
Day1
Day1Day1
Arduino
ArduinoArduino
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
jokersclown57
 
Realization of an 8 bit pipelined microprocessor in verilog hdl
Realization of an 8 bit pipelined microprocessor in verilog hdlRealization of an 8 bit pipelined microprocessor in verilog hdl
Realization of an 8 bit pipelined microprocessor in verilog hdl
Alexander Decker
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignment
babak danyal
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
ShashiKiran664181
 

Similar to coding and wiring dht11 and ultrasonic hcsr04 arduino (20)

Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Distance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino UnoDistance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino Uno
 
selected input/output - sensors and actuators
selected input/output - sensors and actuatorsselected input/output - sensors and actuators
selected input/output - sensors and actuators
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
Temperature Sensor with LED matrix Display BY ►iRFAN QADOOS◄ 9
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Magnetic door lock using arduino
Magnetic door lock using arduinoMagnetic door lock using arduino
Magnetic door lock using arduino
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
Uart
UartUart
Uart
 
code-nodemcu.docx
code-nodemcu.docxcode-nodemcu.docx
code-nodemcu.docx
 
Tdm to vo ip 2
Tdm to vo ip 2Tdm to vo ip 2
Tdm to vo ip 2
 
Day1
Day1Day1
Day1
 
Arduino
ArduinoArduino
Arduino
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
Realization of an 8 bit pipelined microprocessor in verilog hdl
Realization of an 8 bit pipelined microprocessor in verilog hdlRealization of an 8 bit pipelined microprocessor in verilog hdl
Realization of an 8 bit pipelined microprocessor in verilog hdl
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignment
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 

Recently uploaded

Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
The basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptxThe basics of sentences session 7pptx.pptx
The basics of sentences session 7pptx.pptx
 

coding and wiring dht11 and ultrasonic hcsr04 arduino

  • 1. #include <dht11.h> #define DHT11PIN 4 #include <Wire.h> #include <LiquidCrystal_I2C.h>//includesthe LiquidCrystal Library LiquidCrystal_I2Clcd(0x3F,16,2); const inttrigPin= 9; const intechoPin=10; const intbuzzer= 11; const intledPin=13; longduration; intdistance; intSafedistance; dht11 DHT11; voidsetup() { pinMode(trigPin,OUTPUT); pinMode(echoPin,INPUT); pinMode(buzzer,OUTPUT); pinMode(ledPin,OUTPUT); Serial.begin(9600); lcd.begin(); lcd.backlight(); lcd.blink_on() ; } voidloop() { digitalWrite(trigPin,LOW); delayMicroseconds(2); digitalWrite(trigPin,HIGH); delayMicroseconds(10);
  • 2. digitalWrite(trigPin,LOW); duration= pulseIn(echoPin,HIGH); distance=duration*0.034/2; Safedistance =distance; if (Safedistance <=10 ) { digitalWrite(buzzer,HIGH); digitalWrite(ledPin,HIGH); } else{ digitalWrite(buzzer,LOW); digitalWrite(ledPin,LOW); } lcd.print("cm");//Printsstring"Distance"onthe LCD lcd.setCursor(0,0); lcd.print("Distance:"); lcd.print(distance); lcd.print("cm"); Serial.print("Distance:"); Serial.println(distance); intchk = DHT11.read(DHT11PIN); lcd.setCursor(0,1); lcd.print("Temperature:"); lcd.print((float)DHT11.temperature,2); Serial.print("Temperature (C):"); Serial.println((float)DHT11.temperature,2); delay(1000); }