Automatic Fire Security System
Circuit Diagram
#include <Servo.h>
int Servopin=11;
int nofire=0;
int fire=90;
int mospin=5;
Servo myServo;
float inval;
void setup() {
// put your setup code here, to run once:
pinMode(A0,INPUT);
pinMode(mospin,OUTPUT);
Serial.begin(9600);
myServo.attach(Servopin);
}
void loop() {
// put your main code here, to run repeatedly:
inval=analogRead(A0);
Serial.println(inval);
digitalWrite(mospin,LOW);
myServo.write(nofire);
if (inval<100)
{
Serial.println(inval);
digitalWrite(mospin,HIGH);
myServo.write(fire);
}
delay(500);
}
0 Comments