Advertisement
Guest User

maxEmbedded code DC motor control

a guest
Nov 7th, 2013
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <avr/io.h>
  2. #include <util/delay.h>         // for _delay_ms()
  3.  
  4. int main(void)
  5. {
  6.     DDRC = 0x0F;            // initialize port C
  7.                     // motors connected across PC0...Pc3
  8.     while(1)
  9.     {
  10.     // clockwise rotation
  11.     PORTC = 0b00000101;     // PC0 = High = Vcc
  12.                     // PC1 = Low = 0
  13.                     // PC2 = High = Vcc
  14.                     // PC3 = Low = 0
  15.      
  16.     _delay_ms(500);         // wait 0.5s
  17.    
  18.     // counter-clockwise rotation
  19.     PORTC = 0b00001010;     // PC0 = Low = 0
  20.                     // PC1 = High = Vcc
  21.                     // PC2 = Low = 0
  22.                     // PC3 = High = Vcc
  23.      
  24.     _delay_ms(500);         // wait 0.5s
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement