rishi arora
Published © GPL3+

Temperature and Distance Buzzer LED

This device is used to calculate distance, measure temperature and motion, and display it on an output screen.

IntermediateShowcase (no instructions)2 hours898
Temperature and Distance Buzzer LED

Things used in this project

Story

Read more

Schematics

symZBBJm8nIOFNSsyGON.jpg

Code

sketch_dec12d.ino

Java
const int trigPin=7;
const int echoPin=9;
long Duration;
int Distance;
int sensor=11;
int sensor_value;
float temp;
int tempPin=0;

void setup() {
  
  pinMode(2,OUTPUT);
  pinMode(trigPin,OUTPUT);
  pinMode(echoPin,INPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);  
  Serial.begin(9600);
  


}

void loop() 
{
  temp=analogRead(tempPin);
  temp=temp*0.48828125;
  Serial.print("TEMPERATURE= ");
  Serial.print(temp);
  Serial.print("*C");
  Serial.println();
   if(sensor_value==0)
  {
  digitalWrite(trigPin,LOW);
  delayMicroseconds(2000);
    digitalWrite(trigPin,HIGH);
  delayMicroseconds(10000);
 digitalWrite(trigPin,LOW);
  Duration=pulseIn(echoPin,HIGH);
  Distance=Duration*0.034/2;
   Serial.print("Distance: ");
  Serial.println(Distance);
  Serial.print("motion detected"); 
  
  
  }
 if(Distance<20)
  {
    digitalWrite(3,LOW);
    digitalWrite(4,HIGH);
    delay(5);

  Serial.print("TEMPERATURE= ");
  Serial.print(temp);
  Serial.print("*C");
  Serial.println();
  }
  
  if(Distance>21)
   {
    digitalWrite(4,LOW);
    digitalWrite(3,HIGH);
    Serial.print("TEMPERATURE= ");
  Serial.print(temp);
  Serial.print("*C");
  Serial.println();
   }
}

Credits

rishi arora

rishi arora

11 projects • 4 followers

Comments