Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1.  
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #define W0 0x40;
  5. #define W1 0x79;
  6. #define W2 0x24;
  7. #define W3 0x30;
  8. #define W4 0x19;
  9. #define W5 0x12;
  10. #define W6 0x02;
  11. #define W7 0x78;
  12. #define W8 0x00;
  13. #define W9 0x10;
  14. #define E 0x06;
  15. int l;
  16. int main(void)
  17. {
  18. /* Wszystkie linie portu D będą wyjściami */
  19. DDRD = 0xff;
  20.  
  21. /* linie PC0,PC1 będą wejściami z podciągnięciem do VCC */
  22. DDRC = 0x00;
  23. PORTC = 0xFF;
  24. PORTD = W0;
  25. l = 0;
  26.  
  27. /* Początek nieskończonej pętli */
  28. while(1)
  29. {
  30. /* Jeśli pierwszy przycisk wciśnięty */
  31.  
  32. if(!(PINC & 0x01))
  33. l+=1;
  34. if(!(PINC & 0x02))
  35. l-=1;
  36. if(l == 0) PORTD = W0;
  37. if(l == 1) PORTD = W1;
  38. if(l == 2) PORTD = W2;
  39. if(l == 3) PORTD = W3;
  40. if(l == 4) PORTD = W4;
  41. if(l == 5) PORTD = W5;
  42. if(l == 6) PORTD = W6;
  43. if(l == 7) PORTD = W7;
  44. if(l == 8) PORTD = W8;
  45. if(l == 9) PORTD = W9;
  46. if(l == 10) l = 0;
  47. if(l < 0) PORTD = E;
  48. if(l < -1) l = -1;
  49. _delay_ms(50);
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement