Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10. int main(void)
  11. {
  12. DDRD|=((1<<PD0)|(1<<PD1)|(1<<PD2)|(1<<PD3)); //wyjscia mostek h
  13. DDRD|=((1<<PD5)|(1<<PD4)); //wyjscia PWM_1AB
  14. TCCR1A|=((1<<COM1A1)|(1<<COM1B1)); //fast_PWM
  15. TCCR1A|=((1<<WGM12)|(1<<WGM10));
  16. TCCR1B|=((1<<CS11)|(1<<CS10)); //prescaler 64
  17. OCR1A=0;
  18. OCR1B=0;
  19. PORTD|=((1<<PD0)|(1<<PD2));
  20. PORTD&=~((1<<PD1)|(1<<PD3));
  21.  
  22. while (1)
  23. {
  24.  
  25. uint8_t i;
  26. while(i<250)
  27. {
  28. OCR1A=OCR1B=i;
  29. i+=10;
  30. _delay_ms(100);
  31. }
  32. while(i>0)
  33. {
  34. OCR1A=OCR1B=i;
  35. i-=10;
  36. _delay_ms(100);
  37.  
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement