#include <Servo.h>
#include<SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);
int fcr = A0;
int fcr1 = A1;
int value;
int value1;
int pir = 11;
int bazar = 10;
int value2 = LOW;
Servo servo;
int bushbutton = 9;
int LED_R = 13;
int LED_G = 7;
int val ;
int A ;
int flash = 4;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
pinMode(fcr,INPUT);
pinMode(fcr1,INPUT);
pinMode(pir,INPUT);
pinMode(bazar,OUTPUT);
servo.attach(5);
servo.write(90);
pinMode(bushbutton,INPUT);
pinMode(LED_R,OUTPUT);;
pinMode(LED_G,OUTPUT);
pinMode(flash,OUTPUT);
digitalWrite(LED_G,HIGH);
}
void loop() {
value = analogRead (fcr);
value1 = analogRead (fcr1);
value2 = digitalRead(pir);
val = digitalRead(bushbutton);
value = map (value,0,1023,0,255);
value1 = map (value1,0,1023,0,255);
Serial.print("value = ");
Serial.println(value);
Serial.print("value1 = ");
Serial.println(value1);
delay(500);
if ( val == 1)
A= HIGH;
if ( val == 1){
digitalWrite(LED_G,LOW);
digitalWrite(LED_R,HIGH);}
if ( (value>=150 || value1>=150 ) &&( value2==HIGH && A== HIGH))
{
mySerial.println("ATD +966...............;\r");
tone(bazar,880);
servo.write(180);
digitalWrite(flash,HIGH);
delay(100);
digitalWrite(flash,LOW);
delay(100);
}
}