Question
Fix the code: #include const int stepsPerRevolution = 200; Stepper myStepper(stepsPerRevolution, 3, 4, 5, 6); void setup() { Serial.begin(9600); myStepper.setSpeed(90); } void loop () {
Fix the code:
#include
void setup() { Serial.begin(9600); myStepper.setSpeed(90); }
void loop () { if (Serial.available()>0) { char commandChar = Serial.read(); int steps = Serial.parseInt(); switch (commandChar){
case 'a': //CCC Serial.print(" Enter turns:"); int steps = Serial.parseInt(); myStepper.step(stepsPerRevolution*steps); break; case 'b': //CCW Serial.print("Enter turns:"); int steps = Serial.parseInt(); myStepper.step(-steps); break; case 'c': //CSC myStepper.step(stepsPerRevolution); break;
case 'd': //CSW myStepper.step(-stepsPerRevolution); break;
case 'f': //STOP myStepper.setSpeed(0); break;
default: Serial.println("Invalid Command"); }}}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started