Advertisement
ivosexa

Untitled

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