#include <SoftwareSerial.h>
#include <Servo.h>
Servo myservo;
String value;
int TxD = 11;
int RxD = 10;
int pos = 90;
SoftwareSerial bluetooth(TxD, RxD);
void setup() {
Serial.begin(9600);
bluetooth.begin(9600);
myservo.attach(9);
}
void loop() {
Serial.println(value);
if (bluetooth.available()>0)
{
value = bluetooth.readString();
if (value == "aabra ka daabra")
{
Serial.println(pos);
myservo.write(90);
}
while(value=="khul ja sim sim"){
if (bluetooth.available())
{
value = bluetooth.readString();
Serial.println(value);
if (value=="aabra ka daabra")
{
myservo.write(90);
break;
}
}
pos++;
delay(30);
Serial.println(pos);
myservo.write(pos);
if (pos ==90 )
{
pos=0;
break;}
}
}
}