Hello, I'm learning about steppers and need to control one with a radio. I've got a small one connected to an easyDriver and an Arduino UNO with a data pin from an Rx. I've tested my prototype (without the data pin) with this simple code and everything worked fine. I could change the setSpeed() in the code and re-upload and see the changes. I added a few lines to map a variable to the setSpeed so I could control it with an RC, but nothing. I've used this same logic to control an LED so I know I'm close. What's missing?
pulseIn is a function that waits until the signal turns high.
a standard RC-model-radio sends a HIGH-pulse of 1-2 milliseconds once every 50 milliseconds.
1-2 msecs ................50msecs..............1-2 msecs................50msecs..............1-2 msecs................50msecs..............1-2 msecs
A stepper-motor needs a highly regular pulse-train of short high-pulses on the step-input.
let's say the stepper should run at 240 rpm = 4 rps
400 steps per rotation in halfstep-mode = 1600 pulses per second
1/1600 = 625 microseconds
runspeed must be called faster than the steps occur. but with pulsein it can't do that.
So what you need is creating the steppulses "in the backround" or receiving the RC-signal "In the backround"
creating steppulses in the backround
there is another stepmotor-library that can do that. It is called MobaTools. and the function rotate() creates an endless pulsetrain of regular step-pulses at the set speed.
this library can be installed with the library-manager
Follow up: okay that library is annotated in German and a little beyond me at this point. I can accomplish what I need to using servos. Those look more easily controllable using analogRead() for someone at my level.
Another option which would give more flexibility would be to use a second Arduino and a pair of nRF24L01+ transceiver modules to make your own Transmitter. The messages from an nRF24 won't interfere with the stepper pulses.