Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. void setup()
  2. {
  3. DDRD = 0B11111100;
  4. DDRB = 0x01;
  5. Serial.begin(9600);
  6.  
  7. // PORTD = 0xF8;
  8. // PORTB = 0x01;
  9. }
  10.  
  11. int contor = 0, state = 0, old_state = 0;
  12. int state2 = 0, old_state2 = 0;
  13.  
  14. void loop()
  15. {
  16.  
  17. state = PINB & 0b00001000;
  18.  
  19. if (state && (old_state == 0))
  20. {
  21. if (contor == 9)
  22. contor = 0;
  23. else
  24. contor++;
  25. }
  26.  
  27. state2 = PINB & 0b00010000;
  28.  
  29. if (state2 && (old_state2 == 0))
  30. {
  31. if (contor == 0)
  32. contor = 9;
  33. else
  34. contor--;
  35. }
  36.  
  37. Serial.println(contor);
  38.  
  39. switch (contor)
  40. {
  41. case 0:
  42. PORTD = 0xF8;
  43. PORTB = 0x01;
  44. break;
  45.  
  46. case 1:
  47. PORTD = 0x48;
  48. PORTB = 0x00;
  49. break;
  50.  
  51. case 2:
  52. PORTD = 0x9C;
  53. PORTB = 0x01;
  54. break;
  55.  
  56. case 3:
  57. PORTD = 0x5C;
  58. PORTB = 0x01;
  59. break;
  60.  
  61. case 4:
  62. PORTD = 0x6C;
  63. PORTB = 0x00;
  64. break;
  65.  
  66. case 5:
  67. PORTD = 0x74;
  68. PORTB = 0x01;
  69. break;
  70.  
  71. case 6:
  72. PORTD = 0xF4;
  73. PORTB = 0x01;
  74. break;
  75.  
  76. case 7:
  77. PORTD = 0x58;
  78. PORTB = 0x00;
  79. break;
  80.  
  81. case 8:
  82. PORTD = 0xFC;
  83. PORTB = 0x01;
  84. break;
  85.  
  86. case 9:
  87. PORTD = 0x7C;
  88. PORTB = 0x01;
  89.  
  90. }
  91. old_state = state;
  92. old_state2 = state2;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement