hrefab:
2) What it’s doing:
(Via the Serial Monitor)
When I input “SETP#”, the LCD will display the input command on the screen, but the stepper motor does not move.
Well, it won’t respond by moving the motor if cmd is exactly “SETP”. The terminator character # does not get included into the variable cmd.
At first looks, the loop code boils down to this:
If there is any data in the serial read buffer, (it waits 100 miliseconds and clears the lcd screen and…) it’s content and any new data gets dumped to the LCD screen until it is emptied. If any command was sent here it will be ignored. Any partial command would mess up what comes next.
Then it waits for new serial data for 1 second (default timeout) until the # character is received, and puts what is before it into the variable cmd.
If cmd is exactly “GETP” then it prints the CurrentFilter variable, followed by a #, (if not the following…)
If cmd is subsequently exactly “SETP0” is executes SetFilter(0), (if not the following…)
If cmd is subsequently exactly “SETP1” is executes SetFilter(1), (if not the following…)
etc. until SetFilter(4)
The SetFilter code itself looks ok. (except for the second else comment line; it implies filter is lower than Current but it’s actually higher at this else condition) It calls the following EasyDriverStep function depending on the filter selected.
The EasyDriverStep code looks ok too. You probably didn’t change that code and it has run before.
So that means the stepper isn’t turning because the conditions of the if-statements in loop() never matched what you expect cmd to be. You assume it is exactly “GETP” or “SETP#” or whatever number #. But somehow that cmd string is filled with something else unexpected. There may be more characters in it, there may be wrong characters in between (unlikely but potentially posible) or there may be less in it. The simple way to find that out and prove it is by sending back what is in the variable cmd after that is determined.
The while loop dumping the buffer to lcd seems inapropriate. You loose whatever serial commands are sent to it. I don’t understand the need for the delay(100) either, the readStringUntil waits long enough. Remove the while loop. Once you detected the # character and the string cmd is filled, print that to the LCD (and serial port for testing). That should clear up the mists of what is going on exactly.