Guest User

Untitled

a guest
Jun 15th, 2015
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #ifndef F_CPU
  2. #define F_CPU 1000000UL
  3. #endif
  4.  
  5. #include <avr/io.h>
  6.  
  7. #define SERVO_DELTA 500.0
  8. #define SERVO_L_NEUTRAL 1405.0
  9. #define SERVO_R_NEUTRAL 1375.0
  10.  
  11.  
  12. void servo_go(double l, double r)
  13. {
  14.     OCR1A=(int)(SERVO_L_NEUTRAL-l*SERVO_DELTA);
  15.     OCR1B=(int)(SERVO_R_NEUTRAL+r*SERVO_DELTA);
  16. }
  17.  
  18.  
  19. int main()
  20. {
  21.     DDRD|=_BV(DDD4)|_BV(DDD5);
  22.     TCCR1A=_BV(WGM11)|_BV(COM1A1)|_BV(COM1B1);
  23.     TCCR1B=_BV(WGM13)|_BV(WGM12)|_BV(CS10);
  24.     ICR1=19999;
  25.    
  26.     servo_go(1.0, -1.0);
  27.     while (1) {
  28.     }
  29.    
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment