Question: #include Servo myservo; enum { Idle , Degree 0 , Degree 1 8 0 } ; enum { IdleDC , Forward, Backward } ; int

#include
Servo myservo;
enum {Idle, Degree0, Degree180};
enum {IdleDC, Forward, Backward};
int DC1=9;
int DC2=10;
int LED =8;
int SB =6;
int CB =5;
int FB =4;
int BB =3;
int current;
int currentDC;
void setup(){
Serial.begin(9600);
pinMode(DC1, OUTPUT);
pinMode(DC2, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(SB, INPUT_PULLUP);
pinMode(CB, INPUT_PULLUP);
pinMode(FB, INPUT_PULLUP);
pinMode(BB, INPUT_PULLUP);
myservo.attach(11);
current = Idle;
currentDC = IdleDC;
}
void loop(){
switch (current){
case Idle:
digitalWrite(LED, LOW);
myservo.write(90);
delay(15);
if (digitalRead(SB)==0)
current = Degree0;
if (digitalRead(CB)==0)
DCFSM();
break;
case Degree0:
digitalWrite(LED, LOW);
myservo.write(0);
delay(15);
if (digitalRead(SB)==0)
current = Degree180;
if (digitalRead(CB)==0)
DCFSM();
break;
case Degree180:
break;
}
}
void DCFSM(){
while (true){
switch (currentDC){
case IdleDC:
digitalWrite(DC1, LOW);
digitalWrite(DC2, LOW);
digitalWrite(LED, HIGH);
if (digitalRead(FB)==0)
currentDC = Forward;
if (digitalRead(BB)==0)
currentDC = Backward;
break;
case Forward:
break;
case Backward:
digitalWrite(LED, LOW);
digitalWrite(DC1, LOW);
digitalWrite(DC2, HIGH);
delay(3000);
currentDC = IdleDC;
break;
}
if (digitalRead(SB)==0)
break;
}
}
complete missing part of the code ( where the line is )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!