Stepping Motor Control For CSS Compiler




 
#include <16F877.h>
#fuses  XT,NOLVP,NOWDT,NOPROTECT
#use    delay(clock = 4000000)     
#use    fast_io(A)
#use    fast_io(B) 
byte    num[5] = {0x00,0x01,0x02,0x04,0x08};   
int8    disp,i; 
void Forward(){
for(i=0; i<=4;i++){
disp =num[i];
output_b(disp);
delay_ms(200);
}
} 
void Backward(){
for(i=4;i>0;i--){
disp =num[i];
output_b(disp);
delay_ms(200);
}
} 
void Stop(){ 
disp =0;
output_b(disp);
delay_ms(50);
} 
void main(){
setup_adc(adc_off);
set_tris_a(0xFF);           
set_tris_b(0B00000000);
stop();
while(true){
if(!input(pin_a0)){
do{
Forward(); 
} 
while(input(pin_a2));  
}
else if(!input(pin_a1)){  
do{
Backward();
} 
while(input(pin_a2));                    
}
else if(!input(pin_a2)){
Stop();           
}
else{}
}
}

 




Current Project / Post can also be found using:

  • stepper motor ccs compiler project
READ  Analog to dugital 8 bits For Basic PRO Compiler

Leave a Comment

*
= 5 + 7

Read previous post:
fifo-interface
Microchip pic16f877 to FTDI USB interface

Introduction This is a simple design that interfaces a PIC 16F877 microcontroller to the USB bus using the FTDI FT245...

Close
Scroll to top