# Stepper motor

Hello, I am using this code and the ULN2003 to control a 5 pin stepper motor. When I run it nothing happens. Is there anything wrong with this sketch?

////////////////////////////////////////////////////////////////////////////////////////////////////////
const int motorPins={1,4,5,6}; //define pins connected to four phase ABCD of stepping motor
const int CCWStep={0x01,0x02,0x04,0x08}; //define power supply order for coil for rotating anticlockwise
const int CWStep={0x08,0x04,0x02,0x01}; //define power supply order for coil for rotating clockwise
//as for four phase stepping motor, four steps is a cycle. the function is used to drive the stepping motor clockwise or anticlockwise to take four steps
void moveOnePeriod(int dir,int ms){ int i=0,j=0;
for (j=0;j<4;j++){ //cycle according to power supply order
for (i=0;i<4;i++){ //assign to each pin, a total of 4 pins
if(dir == 1) //power supply order clockwise
digitalWrite(motorPins*,(CCWStep[j] == (1<<i)) ? HIGH : LOW); else //power supply order anticlockwise*
digitalWrite(motorPins*,(CWStep[j] == (1<<i)) ? HIGH : LOW);*
}
* if(ms<3)*
speed limit of the motor
* ms=3;*
* delay(ms);*
} }
* //continuous rotation function, the parameter steps specifies the rotation cycles, every four steps is a cycle*
void moveSteps(int dir, int ms, int steps){
* int i;*
* for(i=0;i<steps;i++){*
* moveOnePeriod(dir,ms);*
* }*
}
void motorStop(){ //function used to stop rotating
int i;
for(i=0;i<4;i++){ digitalWrite(motorPins*,LOW);*
} }
int main(void){
* int i;e*
for(i=0;i<4;i++){
pinMode(motorPins*,OUTPUT); }*
* while(1){*
* moveSteps(1,3,512);*
circle, namely, 512 cycles. delay(500);
* moveSteps(0,3,512);*
* delay(500);*
//rotating
360° clockwise, a total of 2048 steps in a
//rotating 360° anticlockwise
}
return 0; }

When I run it nothing happens.

What do you expect the web site to do when that improperly posted code runs? What do you expect the forum to do?

In other words, why did you post in Website and Forum?

``````int main(void){
int i;e
for(i=0;i<4;i++){
pinMode(motorPins,OUTPUT); }
``````

Why do you have a main() when you clearly don’t know everything that main() is supposed to do? You are attempting to set up how the hardware is to work, when you haven’t initialized the hardware.