Guest User

Untitled

a guest
Jul 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. #include <SPI.h>
  2. #include <LiquidCrystal.h>
  3. #include <glcd.h>
  4. #include <fonts/allFonts.h>
  5. #define out1 2
  6. #define out2 3
  7. #define out3 4
  8. #define in 5
  9. #define button 10
  10. unsigned int KMAP[2][4];
  11. String BOOL = "";
  12. String Old = "1";
  13. int A;
  14. String TEST = "Test";
  15.  
  16. void setup()
  17. /* This section sets up the intial conditions required to execute
  18. / all subsequent functions, mostly setting the pins as input
  19. / and output and intializing the LCD libraries.
  20. */
  21. {
  22.  
  23. GLCD.Init(); //Initialize the graphic LCD
  24. GLCD.SelectFont(System5x7); //Select the 5x7 font
  25. pinMode(out1, OUTPUT); //Set these pins to output
  26. pinMode(out2, OUTPUT);
  27. pinMode(out3, OUTPUT);
  28. pinMode(in, INPUT); //Set these pins to input
  29. pinMode(button, INPUT);
  30. //digitalWrite(button, HIGH); //Turn on internal pullup resistor
  31. Serial.begin(9600); //Start serial communication
  32. Serial.println("Serial begin."); //Print the test line
  33.  
  34. }
  35. void loop()
  36. {
  37. if (digitalRead(10) == HIGH){
  38. BOOL = "";
  39. digitalWrite(out1, LOW); //Output C
  40. digitalWrite(out2, LOW); //Output B
  41. digitalWrite(out3, LOW); //Output A
  42. delay(10);
  43. KMAP[0][0] = digitalRead(in); //A'B'C'
  44. digitalWrite(out1, HIGH);
  45. delay(10);
  46. KMAP[1][0] = digitalRead(in); //A'B'C
  47. digitalWrite(out1, LOW);
  48. digitalWrite(out2, HIGH);
  49. delay(10);
  50. KMAP[0][1] = digitalRead(in); //A'BC'
  51. digitalWrite(out1, HIGH);
  52. delay(10);
  53. KMAP[1][1] = digitalRead(in); //A'BC
  54. digitalWrite(out1, LOW);
  55. digitalWrite(out2, LOW);
  56. digitalWrite(out3, HIGH);
  57. delay(10);
  58. KMAP[0][3] = digitalRead(in); //AB'C'
  59. digitalWrite(out1, HIGH);
  60. delay(10);
  61. KMAP[1][3] = digitalRead(in); //AB'C
  62. digitalWrite(out1, LOW);
  63. digitalWrite(out2, HIGH);
  64. delay(10);
  65. KMAP[0][2] = digitalRead(in); //ABC'
  66. digitalWrite(out1, HIGH);
  67. delay(10);
  68. KMAP[1][2] = digitalRead(in); //ABC
  69. if (KMAP[0][0] && KMAP[1][0] && KMAP[0][3] && KMAP[1][3]) {
  70. BOOL += "+ B'";
  71. }
  72. if (KMAP[0][0] && KMAP[1][0] && KMAP[0][1] && KMAP[1][1]) {
  73. BOOL += "+ A' ";
  74. }
  75. if (KMAP[0][1] && KMAP[1][1] && KMAP[0][2] && KMAP[1][2]) {
  76. BOOL += "+ B ";
  77. }
  78. if (KMAP[0][2] && KMAP[1][2] && KMAP[0][3] && KMAP[1][3]) {
  79. BOOL += "+ A ";
  80. }
  81. if (KMAP[0][0] && KMAP[0][1] && KMAP[0][2] && KMAP[0][3]) {
  82. BOOL += "+ C'";
  83. }
  84. if (KMAP[1][0] && KMAP[1][1] && KMAP[1][2] && KMAP[1][3]) {
  85. BOOL += "+ C";
  86. }
  87. if (KMAP[0][0] && KMAP[1][0]) {
  88. BOOL += "+ A'B' ";
  89. }
  90. if (KMAP[0][1] && KMAP[1][1]) {
  91. BOOL += "+ A'B ";
  92. }
  93. if (KMAP[0][2] && KMAP[1][2]) {
  94. BOOL += "+ AB ";
  95. }
  96. if (KMAP[0][3] && KMAP[1][3]) {
  97. BOOL += "+ AB' ";
  98. }
  99. if (KMAP[0][0]) {
  100. BOOL += "+ A'B'C' ";
  101. }
  102. if (KMAP[1][0]) {
  103. BOOL += "+ A'B'C ";
  104. }
  105. if (KMAP[0][1]) {
  106. BOOL += "+ A'BC' ";
  107. }
  108. if (KMAP[1][1]) {
  109. BOOL += "+ A'BC ";
  110. }
  111. if (KMAP[0][2]) {
  112. BOOL += "+ ABC' ";
  113. }
  114. if (KMAP[1][2]) {
  115. BOOL += "+ ABC ";
  116. }
  117. if (KMAP[0][3]) {
  118. BOOL += "+ AB'C' ";
  119. }
  120. if (KMAP[1][3]) {
  121. BOOL += "+ AB'C ";
  122. }
  123. if (Old != BOOL) {
  124. Serial.println(BOOL);
  125. Old = BOOL;
  126. delay(1000);
  127. }
  128. }
  129. }
  130.  
  131.  
  132. void READ()
  133. /* This section is the read and store section; it interacts with
  134. / the outside world via the designated output and input pins.
  135. / This section will write to each output, counting up in binary
  136. / with the MSB called A, and the LSB called C.
  137. */
  138. {
  139.  
  140. }
  141.  
  142. void CONV()
  143. /* This is the Karnaugh mapping section, which checks for contiguous
  144. / sections of true outputs on a grid created in the array BOOL.
  145. / This simplifies the expression by eliminating variables whose level
  146. / is irrelevant because the output is true when it is true or false.
  147. */
  148. {
  149.  
  150. }
  151.  
  152. void DISP()
  153. {
  154.  
  155. }
Add Comment
Please, Sign In to add comment