Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <avr/io.h>
  2.  
  3. void main(void)
  4. {
  5. DDRD &= ~(1<<7); // pin PD7 jako wejście
  6. DDRC |= (1<<7); // pin PC7 jako wyjście
  7.  
  8. PORTD |= (1<<7); // podciągnięcie PD7 do potencjału VCC
  9. PORTC &= ~(1<<7); // ustawienie PC7 na 0, LED2 domyślnie zgaszona
  10.  
  11. while(1)
  12. {
  13. if(bit_is_clear(PIND,7)) // jeśli przycisk S1 wciśniety
  14. {
  15. PORTC |= (1<<7); // zapal diodę LED2
  16. }
  17. else // jeśli przycisk niewciśnięty
  18. {
  19. PORTC &= ~(1<<7); // zgaś diodę LED2
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement