Advertisement
ivosexa

Untitled

Nov 15th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #ifndef motorite
  2. #define motorite
  3.  
  4. #define F_CPU 1000000UL
  5.  
  6.  
  7. #include <avr/io.h>
  8. #include <util/delay.h>
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11.  
  12.  
  13. void move (int pin, int pwm );
  14.  
  15.  
  16.  
  17. void move (int pin, int pwm)
  18.  
  19. {
  20.  
  21. DDRB= 0xff;
  22. PORTB =0x00;
  23. if(pin=1)
  24. {
  25. PORTB |= 1<< PB0 ;
  26. PORTB &= ~(1 << PINB2);
  27. }
  28.  
  29. if(pin=0)
  30. {
  31. PORTB |= 1<< PB2 ;
  32. PORTB &= ~(1 << PINB0);
  33.  
  34. }
  35.  
  36. DDRB |= 1 <<PB1 ;
  37. TCCR1A |= 1<<WGM11 | 1<<COM1A1 ;
  38. TCCR1B |= 1<<WGM13 | 1<<WGM12 | 1<<CS10;
  39. ICR1 = 1024;
  40.  
  41.  
  42.  
  43. OCR1A =pwm;
  44.  
  45.  
  46.  
  47.  
  48. }
  49.  
  50.  
  51.  
  52. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement