#include <Servo.h>
Servo servo_13;
char ch;
int d;
int a;
void setup() {
// put your setup code here, to run once:
pinMode(12, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(2, INPUT);
pinMode(3, INPUT_PULLUP);
servo_13.attach(13);
servo_13.write(90); delay(1000);
Serial.begin(9600);
a=0;
}
void loop() {
// put your main code here, to run repeatedly:
int d=digitalRead(2);
int dc=digitalRead(3);
int l2=analogRead(2);
int l3=analogRead(3);
if (Serial.available()){
ch=Serial.read(); //read as a char data type
Serial.print(ch); //write it back to serial monitor
delay(1000);}
if (ch=="open the door" or d==1 and a==0){
servo_13.write(0);
a=1;
}
if (ch=="close the door" or d==0 and a==1){
servo_13.write(90);
a=0;
}
}