Guest User

CPP file

a guest
Apr 2nd, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. #include "Arduino.h"
  2. #include "FOURDIGITS.h"
  3. FOURDIGITS::FOURDIGITS(){}
  4. void FOURDIGITS::digitInit(uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4);{
  5. Id1=d1;
  6. Id2=d2;
  7. Id3=d3;
  8. Id4=d4;
  9. pinMode(id1,OUTPUT);
  10. pinMode(id2,OUTPUT);
  11. pinMode(id3,OUTPUT);
  12. pinMode(id4,OUTPUT);
  13. }
  14. void FOURDIGITS::segmentInit(uint8_t lA, uint8_t lB, uint8_t lC, uint8_t lD, uint8_t lE, uint8_t lF, uint8_t lG, uint8_t lDP){
  15. ilA=lA;
  16. ilB=lB;
  17. ilC=lC;
  18. ilD=lD;
  19. ilE=lE;
  20. ilF=lF;
  21. ilG=lG;
  22. ilDP=lDP;
  23. pinMode(ilA,OUTPUT);
  24. pinMode(ilB,OUTPUT);
  25. pinMode(ilC,OUTPUT);
  26. pinMode(ilD,OUTPUT);
  27. pinMode(ilE,OUTPUT);
  28. pinMode(ilF,OUTPUT);
  29. pinMode(ilG,OUTPUT);
  30. pinMode(ilDP,OUTPUT);
  31. }
  32. void FORDIGITS::reset(){
  33. digitalWrite(Id1, HIGH);
  34. digitalWrite(Id2, HIGH);
  35. digitalWrite(Id3, HIGH);
  36. digitalWrite(Id4, HIGH);
  37. digitalWrite(ilA,LOW);
  38. digitalWrite(ilB,LOW);
  39. digitalWrite(ilC,LOW);
  40. digitalWrite(ilD,LOW);
  41. digitalWrite(ilE,LOW);
  42. digitalWrite(ilF,LOW);
  43. digitalWrite(ilG,LOW);
  44. digitalWrite(ilDP,LOW);
  45. }
  46.  
  47. void FOURDIGITS::dPoint(uint8_t digit2){
  48. if(digit==1){digitalWrite(Id1, LOW);}
  49. if(digit==2){digitalWrite(Id2, LOW);}
  50. if(digit==3){digitalWrite(Id3, LOW);}
  51. if(digit==4){digitalWrite(Id4, LOW);}
  52. digitalWrite(ilDP, HIGH);
  53. }
  54.  
  55. void FOURDIGITS::swrite(int digit, int num){
  56. reset();
  57. if(digit==1){digitalWrite(Id1, LOW);}
  58. if(digit==2){digitalWrite(Id2, LOW);}
  59. if(digit==3){digitalWrite(Id3, LOW);}
  60. if(digit==4){digitalWrite(Id4, LOW);}
  61.  
  62. if(num==0){
  63. digitalWrite(ilA,HIGH);
  64. digitalWrite(ilB,HIGH);
  65. digitalWrite(ilC,HIGH);
  66. digitalWrite(ilD,HIGH);
  67. digitalWrite(ilE,HIGH);
  68. digitalWrite(ilF,HIGH);
  69. digitalWrite(ilG,LOW);
  70. }
  71.  
  72. if(num==1){
  73. digitalWrite(ilA,LOW);
  74. digitalWrite(ilB,HIGH);
  75. digitalWrite(ilC,HIGH);
  76. digitalWrite(ilD,LOW);
  77. digitalWrite(ilE,LOW);
  78. digitalWrite(ilF,LOW);
  79. digitalWrite(ilG,LOW);
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86. if(num==2){
  87. digitalWrite(ilA,HIGH);
  88. digitalWrite(ilB,HIGH);
  89. digitalWrite(ilC,LOW);
  90. digitalWrite(ilD,HIGH);
  91. digitalWrite(ilE,HIGH);
  92. digitalWrite(ilF,LOW);
  93. digitalWrite(ilG,HIGH);
  94. }
  95.  
  96.  
  97.  
  98. if(num==3){
  99. digitalWrite(ilA,HIGH);
  100. digitalWrite(ilB,HIGH);
  101. digitalWrite(ilC,HIGH);
  102. digitalWrite(ilD,HIGH);
  103. digitalWrite(ilE,LOW);
  104. digitalWrite(ilF,LOW);
  105. digitalWrite(ilG,HIGH);
  106. }
  107.  
  108.  
  109.  
  110. if(num==4){
  111. digitalWrite(ilA,LOW);
  112. digitalWrite(ilB,HIGH);
  113. digitalWrite(ilC,HIGH);
  114. digitalWrite(ilD,LOW);
  115. digitalWrite(ilE,LOW);
  116. digitalWrite(ilF,HIGH);
  117. digitalWrite(ilG,HIGH);
  118. }
  119.  
  120.  
  121. if(num==5){
  122. digitalWrite(ilA,HIGH);
  123. digitalWrite(ilB,LOW);
  124. digitalWrite(ilC,HIGH);
  125. digitalWrite(ilD,HIGH);
  126. digitalWrite(ilE,LOW);
  127. digitalWrite(ilF,HIGH);
  128. digitalWrite(ilG,HIGH);
  129. }
  130.  
  131.  
  132. if(num==6){
  133. digitalWrite(ilA,HIGH);
  134. digitalWrite(ilB,LOW);
  135. digitalWrite(ilC,HIGH);
  136. digitalWrite(ilD,HIGH);
  137. digitalWrite(ilE,HIGH);
  138. digitalWrite(ilF,HIGH);
  139. digitalWrite(ilG,HIGH);
  140. }
  141.  
  142.  
  143.  
  144. if(num==7){
  145. digitalWrite(ilA,HIGH);
  146. digitalWrite(ilB,HIGH);
  147. digitalWrite(ilC,HIGH);
  148. digitalWrite(ilD,LOW);
  149. digitalWrite(ilE,LOW);
  150. digitalWrite(ilF,HIGH);
  151. digitalWrite(ilG,LOW);
  152. }
  153.  
  154.  
  155.  
  156. if(num==8){
  157. digitalWrite(ilA,HIGH);
  158. digitalWrite(ilB,HIGH);
  159. digitalWrite(ilC,HIGH);
  160. digitalWrite(ilD,HIGH);
  161. digitalWrite(ilE,HIGH);
  162. digitalWrite(ilF,HIGH);
  163. digitalWrite(ilG,HIGH);
  164. }
  165.  
  166.  
  167.  
  168. if(num==9){
  169. digitalWrite(ilA,HIGH);
  170. digitalWrite(ilB,HIGH);
  171. digitalWrite(ilC,HIGH);
  172. digitalWrite(ilD,HIGH);
  173. digitalWrite(ilE,LOW);
  174. digitalWrite(ilF,HIGH);
  175. digitalWrite(ilG,HIGH);
  176. }
  177. }
Advertisement
Add Comment
Please, Sign In to add comment