VOICE CONTROL  IRON MAN HELEMT 


CODE :-

 #include "ServoEasing.h"

ServoEasing servoTop;

ServoEasing servoBottom;

// Below numbers should be adjusted in case the facemask does not close/open to desired angle

int bottom_closed = 107;

int top_closed = 167;

int bottom_open = 20;

int top_open = 20;

String inval;

void setup() {

  // put your setup code here, to run once:


Serial.begin(9600);

 servoTop.attach(9);

 servoBottom.attach(10);

 setSpeedForAllServos(190);

 servoTop.setEasingType(EASE_CUBIC_IN_OUT);

 servoBottom.setEasingType(EASE_CUBIC_IN_OUT);

 synchronizeAllServosStartAndWaitForAllServosToStop();

}


void loop() {

  // put your main code here, to run repeatedly:

while (Serial.available()==1){

  inval=Serial.readString();

  Serial.println(inval);

  }

  if (inval=="Friday open the helmet") {

    servoTop.setEaseTo(top_open);

 servoBottom.setEaseTo(bottom_open);

 synchronizeAllServosStartAndWaitForAllServosToStop();

  Serial.println("open");

  inval=Serial.readString();

 delay(600);

 

 

  }

  if (inval=="Friday close the helmet") {

    servoTop.setEaseTo(top_closed);

 delay(500);

 servoBottom.setEaseTo(bottom_closed);

 synchronizeAllServosStartAndWaitForAllServosToStop();

  Serial.println("close");

  inval=Serial.readString();

 delay(600);

  }

}