Friday, June 7, 2013

Microcontroller & DC Motor using transistors

We will make a simple H-Bridge using transistors to use it as an interfacing circuit between micrcontroller and DC motor










Code:

#define M3 PORTC.F0
#define M1 PORTC.F1
#define M4 PORTC.F2
#define M2 PORTC.F3

void main() {
          unsigned char dutyCyle ;
          TRISC = 0 ; PORTC = 0 ;

          M3 = 0 ;
          M2 = 0 ;
          M1 = 0 ;
          M4 = 0 ;
          

          while(1)
          {

              M2 = 0 ; M4 = 0 ;
           
              
              M3 = 0 ; M1 = 1 ;
              
              

              Delay_ms(2000) ;

              M3 = 0 ; M1 = 0 ;
              
              
              M2 = 0 ; M4 = 1 ;
              
           
              Delay_ms(2000) ;
          }
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...