byte directionPin and byte stepPin

Hi all,

I'm just learning about stepper motors. I have 2 questions, some stepper sketches have "byte"in the code like

byte directionPin = 9;
byte stepPin = 8;
int numberOfSteps = 50;
byte ledPin = 13;
int pulseWidthMicros = 50; // microseconds
int millisbetweenSteps = 50; // milliseconds

and some don't. why is that and what does it mean?
2nd question. what does pulseWidthMicros and millisbetweenSteps mean? and how does it relate to stepper motors? (thats 4 questions)lol. you could just give me a link that explains it to me.
Thank you all much!

I want to add that i am controlling a larger driver and stepper motor(5 amp).

Set C++ Variable Types
Byte is a variable type.
It is 8 bits so it can be any number from 0 to 255.
An int on the Arduino is 16 bits.

When you are defining a variable for the first time you must tell the compiler what type it is. byte directionPin = 9; creates a new variable that is a single byte in size and gives it the initial value of 9. int millisbetweenSteps = 50; would create a 2-byte variable and give it a value of 50. To minimize your use of the limited Arduino memory you should use the smallest type of variable that will hold the largest value you are going to use.

Later in your program when you want to use the variable you have already created you do NOT preface it with the type. In other words if you want to change the 50 to 875 you just use millisbetweenSteps = 875; The value 875 would not fit into a byte.

...R

mivison:
2nd question. what does pulseWidthMicros and millisbetweenSteps mean? and how does it relate to stepper motors? (thats 4 questions)lol. you could just give me a link that explains it to me.
Thank you all much!

pulseWidthMicros will be the pulse-width in microseconds - its a parameter to the code.
millisBetweenSteps is the number of milliseconds between each step pulse, again
a parameter to the code.

If you are starting out forget all this and go through the examples for the Stepper library,
then download the AccelStepper library and look at those examples - there are higher
level and easier to get started with I suggest.

MarkT:
If you are starting out forget all this

I suspect the OP got this code from my simple stepper code. I wrote it because it is simpler and more instructive than using a library.

...R