I am using PIC16F628A with uln2003 to drive unipolar stepper motor. Adjusting the delay will increase or decrease the speed of the motor. Here just for demonstration i have taken some delay, you can change it as you want. If you want to change the direction of stepper motor, just reverse the step sequence (means 9,3,6, and C etc).
Code:
void delay();
void main(){
TRISB=0;
while(1){
PORTB = 0x0C;
delay();
PORTB = 0x06;
delay();
PORTB = 0x03;
delay();
PORTB = 0x09;
delay();
}
}
void delay(){
int i;
for(i=0;i<3000;i++);
}
![]() |
| PIC16F628A Stepper Motor Driver |
Delay is same and main routine is like:
Code:
void main(){
while(1){
PORTB = 0x08;
delay();
PORTB = 0x0C;
delay();
PORTB = 0x04;
delay();
PORTB = 0x06;
delay();
PORTB = 0x02;
delay();
PORTB = 0x03;
delay();
PORTB= 0x01;
delay();
PORTB= 0x09;
delay();
}
}
2-Wire Connection:
Delay routine is same. Schematic is here.
Code:
void main(){
while(1){
PORTB = 0x03;
delay();
PORTB = 0x01;
delay();
PORTB = 0x00;
delay();
PORTB = 0x02;
delay();
}}

