Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topic: Stepper Motor Programming Language: Arduino Details:I have problems with the void loop, it only catches the first case and does not do what is

Topic: Stepper Motor

Programming Language: Arduino

Details:I have problems with the void loop, it only catches the first case and does not do what is inside it. I include an image of what the switch/case statement should have and what to do.

image text in transcribed

Code:

#include const int stepsPerRevolution = 200; Stepper myStepper(stepsPerRevolution, 22, 23, 24, 25);

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.read(); myStepper.step(stepsPerRevolution*Steps); break; case 'b': //CCW Serial.print("Enter turns:"); int steps = Serial.read(); 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"); }}}

DO NOT COPY OTHER ANSWER

\begin{tabular}{|c|c|} \hline Keyboard & Port T Function \\ \hline CCC \& number of turns & Move Counter Clock (Continuously) \\ \hline CCW an number of turns & Move Counter Clockwise (Continuously) \\ \hline CSC & Move a numbers of steps CW \\ \hline CSW & Move a numbers of steps \\ CCW \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions