SHARE
TWEET

Programmable Encoder

Braulio777 Jun 25th, 2016 (edited) 191 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Programmable Encoder
  2. int A=A0;//14
  3. int B=A3;//17
  4. int C=A5;//19
  5. int D=2;
  6. int E=A2;//16
  7. int F=A1;//15
  8. int G=A4;//18
  9. int Sw0=13;
  10. int Sw1=12;
  11. int Sw2=11;
  12. int Sw3=10;
  13. int Sw4=9;
  14. int Sw5=8;
  15. int Sw6=7;
  16. int Sw7=6;
  17. int Sw8=5;
  18. int Sw9=4;
  19. int SwClear=3;
  20. void setup(){
  21. pinMode(A, OUTPUT);
  22. pinMode(B, OUTPUT);
  23. pinMode(C, OUTPUT);
  24. pinMode(D, OUTPUT);
  25. pinMode(E, OUTPUT);
  26. pinMode(F, OUTPUT);
  27. pinMode(G, OUTPUT);
  28. pinMode(Sw0, INPUT);
  29. pinMode(Sw1, INPUT);
  30. pinMode(Sw2, INPUT);
  31. pinMode(Sw3, INPUT);
  32. pinMode(Sw4, INPUT);
  33. pinMode(Sw5, INPUT);
  34. pinMode(Sw6, INPUT);
  35. pinMode(Sw7, INPUT);
  36. pinMode(Sw8, INPUT);
  37. pinMode(Sw9, INPUT);
  38. pinMode(SwClear, INPUT);
  39. }
  40. void loop(){
  41. Sw0 = digitalRead(13);
  42. Sw1 = digitalRead(12);
  43. Sw2 = digitalRead(11);
  44. Sw3 = digitalRead(10);
  45. Sw4 = digitalRead(9);
  46. Sw5 = digitalRead(8);
  47. Sw6 = digitalRead(7);
  48. Sw7 = digitalRead(6);
  49. Sw8 = digitalRead(5);
  50. Sw9 = digitalRead(4);
  51. SwClear = digitalRead(3);
  52. if(Sw0==HIGH){
  53. //0
  54. digitalWrite(A, HIGH);
  55. digitalWrite(B, HIGH);
  56. digitalWrite(C, HIGH);
  57. digitalWrite(D, HIGH);
  58. digitalWrite(E, HIGH);
  59. digitalWrite(F, HIGH);
  60. digitalWrite(G, LOW);
  61. }
  62. if(Sw1==HIGH){
  63. //1
  64. digitalWrite(A, LOW);
  65. digitalWrite(B, HIGH);
  66. digitalWrite(C, HIGH);
  67. digitalWrite(D, LOW);
  68. digitalWrite(E, LOW);
  69. digitalWrite(F, LOW);
  70. digitalWrite(G, LOW);
  71. }
  72. if(Sw2==HIGH){
  73. //2
  74. digitalWrite(A, HIGH);
  75. digitalWrite(B, HIGH);
  76. digitalWrite(C, LOW);
  77. digitalWrite(D, HIGH);
  78. digitalWrite(E, HIGH);
  79. digitalWrite(F, LOW);
  80. digitalWrite(G, HIGH);
  81. }
  82. if(Sw3==HIGH){
  83. //3
  84. digitalWrite(A, HIGH);
  85. digitalWrite(B, HIGH);
  86. digitalWrite(C, HIGH);
  87. digitalWrite(D, HIGH);
  88. digitalWrite(E, LOW);
  89. digitalWrite(F, LOW);
  90. digitalWrite(G, HIGH);
  91. }
  92. if(Sw4==HIGH){
  93. //4
  94. digitalWrite(A, LOW);
  95. digitalWrite(B, HIGH);
  96. digitalWrite(C, HIGH);
  97. digitalWrite(D, LOW);
  98. digitalWrite(E, LOW);
  99. digitalWrite(F, HIGH);
  100. digitalWrite(G, HIGH);
  101. }
  102. if(Sw5==HIGH){
  103. //5
  104. digitalWrite(A, HIGH);
  105. digitalWrite(B, LOW);
  106. digitalWrite(C, HIGH);
  107. digitalWrite(D, HIGH);
  108. digitalWrite(E, LOW);
  109. digitalWrite(F, HIGH);
  110. digitalWrite(G, HIGH);
  111. }
  112. if(Sw6==HIGH){
  113. //6
  114. digitalWrite(A, HIGH);
  115. digitalWrite(B, LOW);
  116. digitalWrite(C, HIGH);
  117. digitalWrite(D, HIGH);
  118. digitalWrite(E, HIGH);
  119. digitalWrite(F, HIGH);
  120. digitalWrite(G, HIGH);
  121. }
  122. if(Sw7==HIGH){
  123. //7
  124. digitalWrite(A, HIGH);
  125. digitalWrite(B, HIGH);
  126. digitalWrite(C, HIGH);
  127. digitalWrite(D, LOW);
  128. digitalWrite(E, LOW);
  129. digitalWrite(F, LOW);
  130. digitalWrite(G, LOW);
  131. }
  132. if(Sw8==HIGH){
  133. //8
  134. digitalWrite(A, HIGH);
  135. digitalWrite(B, HIGH);
  136. digitalWrite(C, HIGH);
  137. digitalWrite(D, HIGH);
  138. digitalWrite(E, HIGH);
  139. digitalWrite(F, HIGH);
  140. digitalWrite(G, HIGH);
  141. }
  142. if(Sw9==HIGH){
  143. //9
  144. digitalWrite(A, HIGH);
  145. digitalWrite(B, HIGH);
  146. digitalWrite(C, HIGH);
  147. digitalWrite(D, HIGH);
  148. digitalWrite(E, LOW);
  149. digitalWrite(F, HIGH);
  150. digitalWrite(G, HIGH);
  151. }
  152. if(SwClear==HIGH){
  153. //Clear
  154. digitalWrite(A, LOW);
  155. digitalWrite(B, LOW);
  156. digitalWrite(C, LOW);
  157. digitalWrite(D, LOW);
  158. digitalWrite(E, LOW);
  159. digitalWrite(F, LOW);
  160. digitalWrite(G, LOW);
  161. }
  162. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top