14 Mayıs 2015 Perşembe

Simple fire alarm system with using LM35 and buzzer

Fire alarm system is active when temperature is greater than 50C degree. In this modification we used also TimerOne library for reading the temperature in every 5 seconds. It is modifiable for other projects.

Equipments  :
 - LM35 Temperature Sensor pin
 - Buzzer
 - Arduino Uno
 - Breadboard
 - Jumper Wires






Arduino Code : 

#include <TimerOne.h>
int lm35Pin = 0;
int buzzerPin = 3;
int duration=1000;
int frequency = 262;
float tempVal;
int val;
int flag = 0;

void setup(){
  pinMode(buzzerPin, OUTPUT);
  Timer1.initialize(500000);
  Timer1.attachInterrupt(readTemp);
  Serial.begin(9600);
}
void loop(){
  if(val>10){
    Serial.println("Temperature is to high, fire might be occured!!");
    Serial.println(val);
    buzz();
  }
}
void readTemp(){
  flag++;
  if(flag==12){
    tempVal = analogRead(lm35Pin);
    val = tempVal/2;
   // val = (5.0*100.0)/1024.0;
    flag = 0;
    Serial.print("Temp  :");
    Serial.println(val);
  }
}
void buzz(){
  for(int i = 0;i<4;i++){
    tone(buzzerPin, frequency, duration/2);
    delay(duration);
  }
}


Hiç yorum yok:

Yorum Gönder