You are on page 1of 2

Stepper Motor Interfacing with PIC16F877A

Code:

#include <16f877a.h>
#fuses XT,NOWDT
#use delay (clock=4000000)

#BYTE PORTD = 0x08


#BYTE PORTC = 0x07
#BYTE TRISD = 0x88
#BYTE TRISC = 0x87

#BIT X = PORTC.0
#BIT Y = PORTC.1

void main ()
{
TRISD=0x00;

while (1)
{

delay_ms(500);
PORTD=0b00000001;
delay_ms(500);
PORTD=0b00000011;
delay_ms(500);
PORTD=0b00000010;
delay_ms(500);
PORTD=0b00000110;
delay_ms(500);
PORTD=0b00000100;
delay_ms(500);
PORTD=0b00001100;
delay_ms(500);
PORTD=0b00001000;
delay_ms(500);
PORTD=0b00001001;
delay_ms(500);

}
}