Guest User

Untitled

a guest
Jul 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.01 KB | None | 0 0
  1. int A,B,C,D,E,F,G,H,AB,AC,AE;
  2. #define out1 2
  3. #define out2 3
  4. #define out3 4
  5. #define in 5
  6. #define button 10
  7.  
  8. void setup()  
  9. {
  10.   pinMode(out1, OUTPUT);
  11.   pinMode(out2, OUTPUT);
  12.   pinMode(out3, OUTPUT);
  13.   pinMode(in, INPUT);
  14.   pinMode(button, INPUT);
  15.   digitalWrite(button, HIGH);
  16.   Serial.begin(9600);
  17.   Serial.println("Serial begin.");
  18. }
  19. void loop()  
  20. {
  21.   if (digitalRead(button) == LOW) {
  22.     READ;
  23.     CONV;
  24.     DISP;
  25.   }
  26. }
  27.  
  28.  
  29. void READ()  
  30. {
  31.  
  32.   digitalWrite(out1, LOW);
  33.   digitalWrite(out2, LOW);
  34.   digitalWrite(out3, LOW);
  35.   A = digitalRead(in);       //A'B'C'
  36.   digitalWrite(out1, HIGH);
  37.   B = digitalRead(in);       //AB'C'
  38.   digitalWrite(out1, LOW);
  39.   digitalWrite(out2, HIGH);
  40.   C = digitalRead(in);       //A'BC'
  41.   digitalWrite(out1, HIGH);
  42.   D = digitalRead(in);       //ABC'
  43.   digitalWrite(out1, LOW);
  44.   digitalWrite(out2, LOW);
  45.   digitalWrite(out3, HIGH);
  46.   E = digitalRead(in);       //A'B'C
  47.   digitalWrite(out1, HIGH);
  48.   F = digitalRead(in);       //AB'C
  49.   digitalWrite(out1, LOW);
  50.   digitalWrite(out2, HIGH);
  51.   G = digitalRead(in);       //A'BC
  52.   digitalWrite(out1, HIGH);
  53.   H = digitalRead(in);       //ABC
  54.  
  55. }
  56.  
  57. void CONV()  
  58. {
  59.   if (A == HIGH & B == HIGH) {    //If A'B'C' and AB'C'
  60.     AB = HIGH;                    //then B'C' is true
  61.   }
  62.   if (A == HIGH & C == HIGH) {    //If A'B'C' and A'BC'
  63.     AC = HIGH;                    //then A'C' is true
  64.   }
  65.   if (A == HIGH & E == HIGH) {    //If A'B'C' and A'B'C
  66.     AE = HIGH;                    //then A'B' is true
  67.   }
  68.   if (A == true){
  69. }
  70. }
  71.  
  72. void DISP()
  73. {
  74.  
  75.  if (A == true)  {
  76.    Serial.println("A true");
  77.  }
  78.  if (B == true)  {
  79.    Serial.println("B true");
  80.  }
  81.  if (C == true)  {
  82.    Serial.println("C true");
  83.  }
  84.  if (D == true)  {
  85.    Serial.println("D true");
  86.  }
  87.  if (E == true)  {
  88.    Serial.println("E true");
  89.  }
  90.  if (F == true)  {
  91.    Serial.println("F true");
  92.  }
  93.  Serial.print(B);
  94.  Serial.print(C);
  95.  Serial.print(D);
  96.  Serial.print(E);
  97.  Serial.print(F);
  98.  Serial.print(G);
  99.  Serial.print(H);
  100.  
  101. }
Add Comment
Please, Sign In to add comment