Advertisement
Guest User

Untitled

a guest
May 28th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // Moottorin tehon nosto- ja laskuohjelma by Anton Saarinen, S13VSTG1
  2.  
  3. #ifndef F_CPU
  4. #define F_CPU 16000000UL // 16 MHz clock speed
  5. #endif
  6.  
  7. #include <avr/io.h>
  8. #include <util/delay.h>
  9.  
  10. int main(void)
  11. {
  12. ASSR = 0x00;
  13. TCNT2 = 0x00;
  14. OCR2 = 0x00;
  15. TCCR2 = 0x66;
  16. DDRD = 0xFF;
  17.  
  18. int d=0;
  19.  
  20. while(1) // Loputon looppi
  21.  
  22. {
  23. for(d=0; d<255; d++) // Nostaa tehoa kunnes maksimissa
  24. {
  25. OCR2=d;
  26. _delay_ms(50); // Viive tehon noston välillä
  27. }
  28. for(d=255; d>0; d--) // Laskee tehoa kunnes nollassa
  29. {
  30. OCR2=d;
  31. _delay_ms(50); // Viive tehon laskun välillä
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement