I use Arduino and I'm beginner. I use the code below, but I don't understand what stepper.step(num)
and STEPS
in Stepper stepper(STEPS, 2,3,4,5)
are, and I want to use stepper for specific degree and I don't know what I can do. for example if I want to use stepper for 40 degree what are STEP and num?
#include <Stepper.h>
// change this to the number of steps on your motor
#define STEPS 100
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 2,3,4,5);
// the previous reading from the analog input
int previous = 0;
void setup()
{
// set the speed of the motor to 30 RPMs
stepper.setSpeed(100);
}
void loop()
{
// get the sensor value
//int val = analogRead(0);
// move a number of steps equal to the change in the
// sensor reading
//stepper.step(val - previous);
stepper.step(25);
delay(1000000);
// stepper.step(-5);
// remember the previous value of the sensor
//previous = val;
}
-----------------------------------------EDIT #2----------------------------- my stepper is the first one in this link: https://grahamwideman.wikispaces.com/file/view/28byj48_models_table.jpg/538898220/604x265/28byj48_models_table.jpg ( I think! ) and I don't know what it means? ------------------------------------------EDIT #3---------------------------- Thank you very much, I saw the link.
Step Angle (8-Step sequence: Internal Motor alone): 5.625° (64 steps per revolution)
and I run this code for 45deg :
#include <Stepper.h>
#define STEPS_PER_MOTOR_REVOLUTION 32
#define STEPS_PER_OUTPUT_REVOLUTION 32 * 64 //2048
Stepper small_stepper(STEPS_PER_MOTOR_REVOLUTION, 2, 3, 4, 5);
int Steps2Take;
void setup()
{
}
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
Steps2Take = STEPS_PER_OUTPUT_REVOLUTION / 8.11;
small_stepper.setSpeed(100);
small_stepper.step(Steps2Take);
delay(10000);
}
because I understand each turn has 2048 steps, for example if I want to have 1/2 turn, I have to have num=1024 ( 2048/2). ok, So, for 45deg, it's 1/8 turn so I have to set num=2048/8. but for example for 33 deg what should I do? I thought num= 33*5.61 so for 45deg I use num=45*5.61 you know we have a lot of floating point and I'm not sure we do it correct. right? I'm a little confused.