Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3.  
  4. // definicje dla preprocesora
  5. #define LED_PIN (1<<PD5) // definicja pinu do którego podłączona jest dioda
  6. #define LED_ON PORTD &= ~LED_PIN // makrodefinicja – załączenie diody
  7. #define LED_OFF PORTD |= LED_PIN // makrodefinicja – wyłączenie diody
  8. #define LED_TOG PORTD ^= LED_PIN // makrodefinicja – zmiana stanu diody
  9.  
  10. // ********************************************************* 1-sza wersja
  11. int main(void)
  12. {
  13. // ****** inicjalizacja *********
  14. DDRD |= LED_PIN;
  15.  
  16. // ****** pętla główna programu *********
  17. while(1)
  18. {
  19. LED_ON; // zapal diodę
  20. _delay_ms(1000); // oczekiwanie 1s (1000ms)
  21. LED_OFF; // zgaś diodę
  22. _delay_ms(1000); // oczekiwanie 1s
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement