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{}

   }
}

 

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation and engineering. My writing style is clear and simple, and I am skilled in using infographics and diagrams. I am a great researcher and am able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter