Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef F_CPU
- #define F_CPU 1000000UL
- #endif
- #include <avr/io.h>
- #define SERVO_DELTA 500.0
- #define SERVO_L_NEUTRAL 1405.0
- #define SERVO_R_NEUTRAL 1375.0
- void servo_go(double l, double r)
- {
- OCR1A=(int)(SERVO_L_NEUTRAL-l*SERVO_DELTA);
- OCR1B=(int)(SERVO_R_NEUTRAL+r*SERVO_DELTA);
- }
- int main()
- {
- DDRD|=_BV(DDD4)|_BV(DDD5);
- TCCR1A=_BV(WGM11)|_BV(COM1A1)|_BV(COM1B1);
- TCCR1B=_BV(WGM13)|_BV(WGM12)|_BV(CS10);
- ICR1=19999;
- servo_go(1.0, -1.0);
- while (1) {
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment