CODE:-
int first=9;
int second=10;
int third=11;
int forth=12;
String inval;
int wait=7000;
void setup() {
// put your setup code here, to run once:
pinMode(first,OUTPUT);
pinMode(second,OUTPUT);
pinMode(third,OUTPUT);
pinMode(forth,OUTPUT);
Serial.begin(9600);
digitalWrite(first,HIGH);
digitalWrite(second,HIGH);
digitalWrite(third,HIGH);
digitalWrite(forth,HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available()==1){
inval=Serial.readString();
Serial.println(inval);
}
inval=Serial.readString();
Serial.println(inval);
if (inval=="launch first rocket") {
digitalWrite(first,LOW);
inval=Serial.readString();
delay(wait);
digitalWrite(first,HIGH);
}
if (inval=="launch second rocket") {
digitalWrite(second,LOW);
inval=Serial.readString();
delay(wait);
digitalWrite(second,HIGH);
}
if (inval=="launch third rocket") {
digitalWrite(third,LOW);
inval=Serial.readString();
delay(wait);
digitalWrite(third,HIGH);
}
if (inval=="launch forth rocket") {
digitalWrite(forth,LOW);
inval=Serial.readString();
delay(wait);`
digitalWrite(forth,HIGH);
}
if (inval=="launch all") {
digitalWrite(first,LOW);
digitalWrite(second,LOW);
digitalWrite(third,LOW);
digitalWrite(forth,LOW);
inval=Serial.readString();
delay(wait);
digitalWrite(first,HIGH);
digitalWrite(second,HIGH);
digitalWrite(third,HIGH);
digitalWrite(forth,HIGH);
}
}
0 Comments