Talk:Arduino/Motor Control/steppermotors

From Wikiversity
Jump to navigation Jump to search

Because steppers hold their position until you tell them to “step” you can easily control their speed with some great advantages. Unlike a typical motor, steppers actually are stronger when moving slower. And… You don’t change the amount of power to the motor to control its speed – In fact, you almost never need to change the amount of power to the motor – So just give it what it needs, and keep it that way.

program issues[edit source]

The program shown is for attaching a stepper to a motor driver chip using additional hardware. A two-pin connection is somewhat advanced use. A beginner would use a four-pin layout (along with a motor driver chip). There is no configuration which allows the stepper to be directly attached to the Arduino. Further information can be seen here, where the code originated from: http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors/

BTW- that last section of code is a function called blink, it uses an int (integer) passed from when the function is called, and names it howManyTimes (in setup it says blink(3), so in this case howManyTimes would be equal to 3).

The i is the variable name used in this FOR loop. i++ is the same as typing i=i+1, which means add 1 to the current value of i. The FOR loop will repeat everything in the following brackets, until it's conditions are met, in this case, i will eventually become equal to 3, and that will end the loop. The int which is seen in various places in the program, is a reference to an Integer-type variable being "declared" (announced.. first used, etc.) the actual variable name "i" could have been anything.. another letter, or word, and it would function the same.

For the record, the "blink" function is only called once during this program because it's in the setup() portion of the "sketch" (program). If you removed it from the setup, you could remove the function itself from the script. It appears that the author merely wanted the LED at pin 13 (built-in, with a resistor, on many arduino models), to flash 3 times, indicating to them (or the user) that the setup portion of the program was completed. Sometimes that's useful because the serial connection might have issues and get stuck, for example, it's my understanding that if you used a Leonardo arduino, it would require you to already have the serial monitor open before allowing it to set the serial communications.