Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int A,B,C,D,E,F,G,H,AB,AC,AE;
- #define out1 2
- #define out2 3
- #define out3 4
- #define in 5
- #define button 10
- void setup()
- {
- pinMode(out1, OUTPUT);
- pinMode(out2, OUTPUT);
- pinMode(out3, OUTPUT);
- pinMode(in, INPUT);
- pinMode(button, INPUT);
- digitalWrite(button, HIGH);
- Serial.begin(9600);
- Serial.println("Serial begin.");
- }
- void loop()
- {
- if (digitalRead(button) == LOW) {
- READ;
- CONV;
- DISP;
- }
- }
- void READ()
- {
- digitalWrite(out1, LOW);
- digitalWrite(out2, LOW);
- digitalWrite(out3, LOW);
- A = digitalRead(in); //A'B'C'
- digitalWrite(out1, HIGH);
- B = digitalRead(in); //AB'C'
- digitalWrite(out1, LOW);
- digitalWrite(out2, HIGH);
- C = digitalRead(in); //A'BC'
- digitalWrite(out1, HIGH);
- D = digitalRead(in); //ABC'
- digitalWrite(out1, LOW);
- digitalWrite(out2, LOW);
- digitalWrite(out3, HIGH);
- E = digitalRead(in); //A'B'C
- digitalWrite(out1, HIGH);
- F = digitalRead(in); //AB'C
- digitalWrite(out1, LOW);
- digitalWrite(out2, HIGH);
- G = digitalRead(in); //A'BC
- digitalWrite(out1, HIGH);
- H = digitalRead(in); //ABC
- }
- void CONV()
- {
- if (A == HIGH & B == HIGH) { //If A'B'C' and AB'C'
- AB = HIGH; //then B'C' is true
- }
- if (A == HIGH & C == HIGH) { //If A'B'C' and A'BC'
- AC = HIGH; //then A'C' is true
- }
- if (A == HIGH & E == HIGH) { //If A'B'C' and A'B'C
- AE = HIGH; //then A'B' is true
- }
- if (A == true){
- }
- }
- void DISP()
- {
- if (A == true) {
- Serial.println("A true");
- }
- if (B == true) {
- Serial.println("B true");
- }
- if (C == true) {
- Serial.println("C true");
- }
- if (D == true) {
- Serial.println("D true");
- }
- if (E == true) {
- Serial.println("E true");
- }
- if (F == true) {
- Serial.println("F true");
- }
- Serial.print(B);
- Serial.print(C);
- Serial.print(D);
- Serial.print(E);
- Serial.print(F);
- Serial.print(G);
- Serial.print(H);
- }
Add Comment
Please, Sign In to add comment