rishi arora
Published © GPL3+

Temperature detection alarm

This device will ring the buzzer ,calculate and display the nearest object distance and temperature ,to an output scren

IntermediateProtip1.5 hours2,104
Temperature detection alarm

Things used in this project

Story

Read more

Code

Untitled file

Java
const int trigPin = 7;
const int echoPin =10;
long duration;
int distance;
int ledPin = 13;
int inputPin = 2;
int pirState = LOW;
int val = 0;
float temp;
int tempPin = 0;
float f;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(inputPin, INPUT);
Serial.begin(9600);
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
Serial.begin(9600);
pinMode(12,OUTPUT);
}
void loop(){
temp=analogRead(tempPin);
temp=temp*0.48828125;
f=temp*9/5+32;
digitalWrite(trigPin,LOW);
delayMicroseconds(2);
digitalWrite(trigPin,HIGH);
digitalWrite(trigPin,LOW);
duration=pulseIn(echoPin,HIGH);
distance=duration*0.034/2;
val = digitalRead(inputPin);
 if (val == HIGH) {
 digitalWrite(ledPin, HIGH);
 if (pirState == LOW) {
 Serial.println("Motion detected!");
 Serial.print("Temperature= “);
Serial.print(temp);
Serial.print("*C and ");
Serial.print(f);
Serial.print("*f");
Serial.println();
delay(1000);
Serial.print("Someone is at a distace of ");
Serial.println(distance);
pirState = HIGH;
if((temp>=35)||(temp<=25))
{digitalWrite(ledPin, HIGH);
delayMicreoseconds(20);
Serial.print(“ Beware ! Temperature is exceeding the safe range”);}
else
{Serial.print(“HURRY UP”);
}}}
 else {
 digitalWrite(ledPin, LOW);
 if (pirState == HIGH)
{Serial.println("Motion ended!");
 pirState = LOW;
 }}}

Credits

rishi arora

rishi arora

11 projects • 4 followers

Comments