Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- // definicje dla preprocesora
- #define LED_PIN (1<<PD5) // definicja pinu do którego podłączona jest dioda
- #define LED_ON PORTD &= ~LED_PIN // makrodefinicja – załączenie diody
- #define LED_OFF PORTD |= LED_PIN // makrodefinicja – wyłączenie diody
- #define LED_TOG PORTD ^= LED_PIN // makrodefinicja – zmiana stanu diody
- // ********************************************************* 1-sza wersja
- int main(void)
- {
- // ****** inicjalizacja *********
- DDRD |= LED_PIN;
- // ****** pętla główna programu *********
- while(1)
- {
- LED_ON; // zapal diodę
- _delay_ms(1000); // oczekiwanie 1s (1000ms)
- LED_OFF; // zgaś diodę
- _delay_ms(1000); // oczekiwanie 1s
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement