MoCo Update: Stepper Motor Controller Test Code

Alright, so this is really a follow-up to my previous post, but here's the code I used to verify the functionality of my 2-input/motor stepper controller. Note: pins 2&3 were for one stepper motor, pins 4&5 were for another. This code rotates two motors in the same direction.The program has 2 global variables, one to keep track of the current step-position of the motor, and one that's essentially a clockwise/counter-clockwise flag. The setup function initializes the pins of interest to do digital writes, otherwise instead of seeing 0 and 5 volts LOW-HIGH, it'll come out like - 5 volts). Pin 13 is for an LED which is fairly inconsequential, and the serial setup is for the Arduino to stream back debugging statements to the computer "base station."The function I wrote to replace the default 4-wire "stepper()" function is called write2Bits(). It takes in which "step" to write (integer between 1-4) and the pins representing the first and second bit of the step. Inside is a case statement that maps the "step" to the appropriate output.Because I didn't have any documentation that came with my stepper motors, I had to find out through trial and error which pins were 1-4. It turns out that the pin assignments were interleaved on the header, so instead of writing "LOW,LOW" for [step 1 - binary number 0], I actually ended up writing "HIGH,HIGH". 2, 3, and 4 were also different than expected. Between my code and the pictures of the actual setup (shown again below) and some trial and error, you should be able to wire up your own motor.If you have any questions, or want to download my Arduino program, feel free to contact me. Otherwise, happy tinkering!

Previous
Previous

iMovie Troubleshooting: Connection Failed, Server Does Not Exist [FIX]

Next
Next

Moco Update: Stepper Motor Controller Complete