Test AND, OR, NOT and other logic IC gates with Arduino MEGA and it's 5" touch screen to select and view Truth Table.

Enjoy testing IC logic gates through this Touch System

Schematic

Remember after this wiring to assembling Arduino MEGA with TFT Shield and finally install 5" TFT screen

schm.jpg


    #include <SPI.h>            // Librería para usar tarjeta SD
#include <SdFat.h>          // Complemento para Usar tarjeta SD
#include <UTFT_SdRaw.h>     // Complement para usar tarjeta SD
#define SD_CHIP_SELECT  53  // SD chip select pin
#include <UTFT.h>  // Librería para habilitar pantalla TFT
#include <UTouch.h>
UTouch  myTouch( 6, 5, 4, 3, 8);
SdFat sd;
UTFT myGLCD(CTE50,38,39,40,41);   // Definición de pines para habilitar pantalla LCD
UTFT_SdRaw myFiles(&myGLCD);      // Comando para acelerar la carga de imágenes
const int LUZlcd = 44;
int brightness   = 0;
int x,y;

extern uint8_t OCR_A_Extended_M[];
int draw =0;
int test =0;
int logic=0;
int gate=0;
int ejercicio=0;

int ANDstate   =0;
int ORstate    =0;
int NOTstate   =0;
int BUFFERstate=0;
int NANDstate  =0;
int NORstate   =0;
int XNORstate  =0;
int XORstate   =0;

const int out1 = 8; // patilla #1 en IC
const int out2 = 9; // patilla #2 en IC
const int out3 = 10;// patilla #3 en IC
const int out4 = 11;// patilla #4 en IC
const int out5 = 12;// patilla #5 en IC
const int out6 = A0;// patilla #6 en IC
const int out7 = A1;// patilla #8 en IC
const int out8 = A2;// patilla #9 en IC
const int out9 = A3;// patilla #10 en IC
const int out10= A4;// patilla #11 en IC
const int out11= A5;// patilla #12 en IC
const int out12= A6;// patilla #13 en IC

int read1;
int read2;
int read3;
int read4;
int read5;
int read6;


void setup() {
    myGLCD.InitLCD();
    pinMode(LUZlcd, OUTPUT);
    myTouch.InitTouch();
    myTouch.setPrecision(PREC_HI);
    Serial.println(F("Initialising SD card..."));
  bool mysd = 0;  // see if the card is present and can be initialized:
  while (!mysd)
  {
    if (!sd.begin(SD_CHIP_SELECT, SPI_FULL_SPEED)) {
     Serial.println(F("Card failed, or not present"));
     Serial.println(F("Retrying...."));
    }
    else
    {
      mysd = 1;
     Serial.println(F("Card initialised."));
    }  
  } 
    
    Serial.begin(9600);
    while (!Serial); // wait for Leonardo enumeration, others continue immediately
PP();
  myGLCD.setFont(OCR_A_Extended_M);
  myGLCD.setBackColor(32,32,228);
  myGLCD.setColor(VGA_BLACK);
  myGLCD.fillRect(137,17,152,32);
  myGLCD.fillRect(247,17,262,32);
  myGLCD.fillRect(356,17,371,32);
  myGLCD.fillRect(465,17,480,32);
  myGLCD.fillRect(138,104,153,119);
  myGLCD.fillRect(247,104,262,119);
  myGLCD.fillRect(356,104,371,119);
  myGLCD.fillRect(465,104,480,119);
  myGLCD.setColor(VGA_YELLOW);
  myGLCD.print("Y",710,55);
  myGLCD.print(" ",590,55);
  myGLCD.print(" ",615,55);
  myGLCD.print(" ",640,55);
}

void loop() {
  
  Serial.print ("dentro de LOOP");
  while (myTouch.dataAvailable() == true)
  {
    myTouch.read();
    x = myTouch.getX();
    y = myTouch.getY();
    if ((x!=-1) and (y!=-1))
    {
      Serial.print(x);
      Serial.print(" X ");
      Serial.print(y);
      Serial.println(" Y ");
   //  myGLCD.drawPixel (x, y);
    }

    // Test button 
    if ((y>=320) && (y<=430)){
      if ((x>=600) && (x<=710)){
        test = 1;
        // If some logic GATE has been selected then set Circuit to TEST
    if (logic >=1){
      Serial.println("dentro de IF LOGIC");
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(578,95,670,280);
      myGLCD.fillRect(688,95,747,280);
      ANDstate   =0;
      ORstate    =0;
      NOTstate   =0;
      BUFFERstate=0;
      NANDstate  =0;
      NORstate   =0;
      XNORstate  =0;
      XORstate   =0;
      TEST();
    }
        delay(300);
      }
    }
    circuitos();
  }
}

    // Primera Pantalla
void PP(){
  myFiles.load(0,0, 800,480, "main.RAW");
  digitalWrite(LUZlcd, HIGH);
  }


void circuitos(){
    
      // Seleccion AND GATE
   if ((y>=20) && (y<=74)){
      if ((x>=70) && (x<=145)){
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(247,17,262,32);
      myGLCD.fillRect(356,17,371,32);
      myGLCD.fillRect(465,17,480,32);
      myGLCD.fillRect(138,104,153,119);
      myGLCD.fillRect(247,104,262,119);
      myGLCD.fillRect(356,104,371,119);
      myGLCD.fillRect(465,104,480,119);  
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(137,17,152,32);
      myFiles.load(54,255, 426,164, "and.RAW");
      myGLCD.print("A",590,55);
      myGLCD.print(" ",615,55);
      myGLCD.fillCircle(623,65,4);
      myGLCD.print("B",640,55);
      myGLCD.setColor(32,32,228);
      myGLCD.drawLine(590,48,657,48);
      myGLCD.drawLine(590,49,657,49);
      myGLCD.drawCircle(623,65,10);
      myGLCD.setColor(VGA_YELLOW);
      pinMode(out1, OUTPUT);
      pinMode(out2, OUTPUT);
      pinMode(out3,  INPUT);
      pinMode(out4, OUTPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6,  INPUT);
      pinMode(out7,  INPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9, OUTPUT);
      pinMode(out10, INPUT);
      pinMode(out11,OUTPUT);
      pinMode(out12,OUTPUT);
      test  = 1;
      logic = 1; 
      ejercicio = 0;
      x=0;
      y=0;
      ANDstate=0;
    }
  }
     // Seleccion OR GATE
     if ((y>=20) && (y<=74)){
      if ((x>=180) && (x<=255)){
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(137,17,152,32);
      myGLCD.fillRect(356,17,371,32);
      myGLCD.fillRect(465,17,480,32);
      myGLCD.fillRect(138,104,153,119);
      myGLCD.fillRect(247,104,262,119);
      myGLCD.fillRect(356,104,371,119);
      myGLCD.fillRect(465,104,480,119);  
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(247,17,262,32);
      myFiles.load(54,255, 426,164,  "or.RAW");
      myGLCD.print("A",590,55);
      myGLCD.print("+",615,55);
      myGLCD.print("B",640,55);
      myGLCD.setColor(32,32,228);
      myGLCD.drawLine(590,48,657,48);
      myGLCD.drawLine(590,49,657,49);
      myGLCD.drawCircle(623,65,10);
       myGLCD.setColor(VGA_YELLOW);
       pinMode(out1, OUTPUT);
      pinMode(out2, OUTPUT);
      pinMode(out3,  INPUT);
      pinMode(out4, OUTPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6,  INPUT);
      pinMode(out7,  INPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9, OUTPUT);
      pinMode(out10, INPUT);
      pinMode(out11,OUTPUT);
      pinMode(out12,OUTPUT);
      test  = 1;
      logic = 2; 
      ejercicio = 0;
      x=0;
      y=0;
      ORstate=0;
    }
  }
     // Seleccion NOT GATE
     if ((y>=20) && (y<=74)){
      if ((x>=290) && (x<=365)){
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(137,17,152,32);
      myGLCD.fillRect(247,17,262,32);
      myGLCD.fillRect(465,17,480,32);
      myGLCD.fillRect(138,104,153,119);
      myGLCD.fillRect(247,104,262,119);
      myGLCD.fillRect(356,104,371,119);
      myGLCD.fillRect(465,104,480,119);  
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(356,17,371,32);
       myFiles.load(54,255, 426,164, "not.RAW");
       myGLCD.print(" ",590,55);
       myGLCD.print("A",615,55);
       myGLCD.setColor(32,32,228);
       myGLCD.drawLine(590,48,657,48);
       myGLCD.drawLine(590,49,657,49);
       myGLCD.drawCircle(623,65,10);
       myGLCD.setColor(VGA_YELLOW);
       myGLCD.drawLine(615,48,633,48);
       myGLCD.drawLine(615,49,633,49);
       myGLCD.print(" ",640,55);
       pinMode(out1,OUTPUT);
      pinMode(out2,  INPUT);
      pinMode(out3, OUTPUT);
      pinMode(out4,  INPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6,  INPUT);
      pinMode(out7,  INPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9,  INPUT);
      pinMode(out10,OUTPUT);
      pinMode(out11, INPUT);
      pinMode(out12,OUTPUT);
      test  = 1;
      logic = 3; 
      ejercicio = 0;
      x=0;
      y=0;
      NOTstate=0;
    }
  }

      // Seleccion BUFFER GATE
     if ((y>=20) && (y<=74)){
      if ((x>=400) && (x<=475)){
       myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(137,17,152,32);
      myGLCD.fillRect(247,17,262,32);
      myGLCD.fillRect(356,17,371,32);
      myGLCD.fillRect(138,104,153,119);
      myGLCD.fillRect(247,104,262,119);
      myGLCD.fillRect(356,104,371,119);
      myGLCD.fillRect(465,104,480,119);  
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(465,17,480,32);
       myFiles.load(54,255, 426,164, "buffer.RAW");
       myGLCD.print(" ",590,55);
       myGLCD.print("A",615,55);
       myGLCD.print(" ",640,55);
       myGLCD.setColor(32,32,228);
       myGLCD.drawLine(590,48,657,48);
       myGLCD.drawLine(590,49,657,49);
       myGLCD.drawCircle(623,65,10);
       myGLCD.setColor(VGA_YELLOW);
      pinMode(out1,OUTPUT);
      pinMode(out2,  INPUT);
      pinMode(out3, OUTPUT);
      pinMode(out4,  INPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6,  INPUT);
      pinMode(out7,  INPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9,  INPUT);
      pinMode(out10,OUTPUT);
      pinMode(out11, INPUT);
      pinMode(out12,OUTPUT);
      test  = 1;
      logic = 4; 
      ejercicio = 0;
      x=0;
      y=0;
    }
  }

  // Seleccion NAND GATE
     if ((y>=100) && (y<=168)){
      if ((x>=70) && (x<=145)){
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(137,17,152,32);
      myGLCD.fillRect(247,17,262,32);
      myGLCD.fillRect(356,17,371,32);
      myGLCD.fillRect(465,17,480,32);
      myGLCD.fillRect(247,104,262,119);
      myGLCD.fillRect(356,104,371,119);
      myGLCD.fillRect(465,104,480,119);  
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(138,104,153,119);
      myFiles.load(54,255, 426,164, "nand.RAW");
      myGLCD.print("A",590,55);
      myGLCD.print(" ",615,55);
      myGLCD.fillCircle(623,65,4);
      myGLCD.print("B",640,55);
      myGLCD.drawLine(590,48,657,48);
      myGLCD.drawLine(590,49,657,49);
      myGLCD.setColor(32,32,228);
      myGLCD.drawCircle(623,65,10);
      myGLCD.setColor(VGA_YELLOW);
      pinMode(out1, OUTPUT);
      pinMode(out2, OUTPUT);
      pinMode(out3,  INPUT);
      pinMode(out4, OUTPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6,  INPUT);
      pinMode(out7,  INPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9, OUTPUT);
      pinMode(out10, INPUT);
      pinMode(out11,OUTPUT);
      pinMode(out12,OUTPUT);
      test  = 1;
      logic = 5; 
      ejercicio = 0;
      x=0;
      y=0;
      NANDstate=0;
    }
  }

  // Seleccion NOR GATE
     if ((y>=100) && (y<=168)){
      if ((x>=180) && (x<=255)){
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(137,17,152,32);
      myGLCD.fillRect(247,17,262,32);
      myGLCD.fillRect(356,17,371,32);
      myGLCD.fillRect(465,17,480,32);
      myGLCD.fillRect(138,104,153,119);
      myGLCD.fillRect(356,104,371,119);
      myGLCD.fillRect(465,104,480,119);  
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(247,104,262,119);
      myFiles.load(54,255, 426,164, "nor.RAW");
      myGLCD.print("A",590,55);
      myGLCD.print("+",615,55);
      myGLCD.print("B",640,55);
      myGLCD.drawLine(590,48,657,48);
      myGLCD.drawLine(590,49,657,49);
      pinMode(out1,  INPUT);
      pinMode(out2, OUTPUT);
      pinMode(out3, OUTPUT);
      pinMode(out4,  INPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6, OUTPUT);
      pinMode(out7, OUTPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9,  INPUT);
      pinMode(out10,OUTPUT);
      pinMode(out11,OUTPUT);
      pinMode(out12, INPUT);
      test  = 1;
      logic = 6; 
      ejercicio = 0;
      x=0;
      y=0;
    }
  }

  // Seleccion XNOR GATE
     if ((y>=100) && (y<=168)){
      if ((x>=290) && (x<=365)){
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(137,17,152,32);
      myGLCD.fillRect(247,17,262,32);
      myGLCD.fillRect(356,17,371,32);
      myGLCD.fillRect(465,17,480,32);
      myGLCD.fillRect(138,104,153,119);
      myGLCD.fillRect(247,104,262,119);
      myGLCD.fillRect(465,104,480,119);  
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(356,104,371,119);
      myFiles.load(54,255, 426,164, "xnor.RAW");
      myGLCD.print("A",590,55);
      myGLCD.print("+",615,55);
      myGLCD.print("B",640,55);
      myGLCD.drawCircle(623,65,10);
      myGLCD.drawLine(590,48,657,48);
      myGLCD.drawLine(590,49,657,49);
      pinMode(out1, OUTPUT);
      pinMode(out2, OUTPUT);
      pinMode(out3,  INPUT);
      pinMode(out4,  INPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6, OUTPUT);
      pinMode(out7, OUTPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9,  INPUT);
      pinMode(out10, INPUT);
      pinMode(out11,OUTPUT);
      pinMode(out12,OUTPUT);
      test  = 1;
      logic = 7; 
      ejercicio = 0;
      x=0;
      y=0;
    }
  }

  // Seleccion XOR GATE
     if ((y>=100) && (y<=168)){
      if ((x>=400) && (x<=475)){
      myGLCD.setColor(VGA_BLACK);
      myGLCD.fillRect(137,17,152,32);
      myGLCD.fillRect(247,17,262,32);
      myGLCD.fillRect(356,17,371,32);
      myGLCD.fillRect(465,17,480,32);
      myGLCD.fillRect(138,104,153,119);
      myGLCD.fillRect(247,104,262,119);
      myGLCD.fillRect(356,104,371,119);
      myGLCD.setColor(VGA_LIME);
      myGLCD.fillRect(465,104,480,119);
      myFiles.load(54,255, 426,164, "xor.RAW");
      myGLCD.print("A",590,55);
      myGLCD.print("+",615,55);
      myGLCD.print("B",640,55);
      myGLCD.drawCircle(623,65,10);
      myGLCD.setColor(32,32,228); 
      myGLCD.drawLine(590,48,657,48);
      myGLCD.drawLine(590,49,657,49);
      myGLCD.setColor(VGA_YELLOW);
      pinMode(out1, OUTPUT);
      pinMode(out2, OUTPUT);
      pinMode(out3,  INPUT);
      pinMode(out4, OUTPUT);
      pinMode(out5, OUTPUT);
      pinMode(out6,  INPUT);
      pinMode(out7,  INPUT);
      pinMode(out8, OUTPUT);
      pinMode(out9, OUTPUT);
      pinMode(out10, INPUT);
      pinMode(out11,OUTPUT);
      pinMode(out12,OUTPUT);
      test  = 1;
      logic = 8; 
      ejercicio = 0;
      x=0;
      y=0;
     }
    }
   }
  
void TEST(){
  switch (logic){
    case 1: // Ejecuta test a compuerta AND
            // Entrada 0 y 0 en GATE 1
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.print("GATE 1",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(53,418,58,364);
        myGLCD.fillRect(59,364,133,368);
        myGLCD.fillRect(117,418,122,383);
        myGLCD.fillRect(123,383,133,387);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out1, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out2, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          ANDstate = ANDstate+1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out1, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out2, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(53,418,58,364);
           myGLCD.fillRect(59,364,133,368);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out1, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out2, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(53,418,58,364);
           myGLCD.fillRect(59,364,133,368);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out1, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out2, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
        delay(1000);

        
               // Entrada 0 y 0 en GATE 2
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 2",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(264,418,269,364);
        myGLCD.fillRect(270,364,352,369);
        myGLCD.fillRect(336,418,341,383);
        myGLCD.fillRect(342,383,355,387);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out4, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out5, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out4, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out5, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(264,418,269,364);
           myGLCD.fillRect(270,364,352,369);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out4, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out5, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(264,418,269,364);
           myGLCD.fillRect(270,364,352,369);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out4, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out5, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
         delay(1000);
         
          // Entrada 0 y 0 en GATE 3
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 3",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(412,254,417,269);
        myGLCD.fillRect(395,264,413,269);
        myGLCD.fillRect(395,269,399,293);
        myGLCD.fillRect(400,288,414,293);
        myGLCD.fillRect(339,254,344,312);
        myGLCD.fillRect(345,307,414,312);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out8, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out9, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out8, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out9, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(412,254,417,269);
           myGLCD.fillRect(395,264,413,269);
           myGLCD.fillRect(395,269,399,293);
           myGLCD.fillRect(400,288,414,293);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out8, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out9, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(412,254,417,269);
           myGLCD.fillRect(395,264,413,269);
           myGLCD.fillRect(395,269,399,293);
           myGLCD.fillRect(400,288,414,293);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out8, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out9, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

delay(1000);
         
          // Entrada 0 y 0 en GATE 4
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 4",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(191,254,196,292);
        myGLCD.fillRect(192,289,208,294);
        myGLCD.fillRect(115,254,120,311);
        myGLCD.fillRect(117,307,208,312);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out11, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out12, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out11, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out12, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(191,254,196,292);
           myGLCD.fillRect(192,289,208,294);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out11, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out12, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(191,254,196,292);
           myGLCD.fillRect(192,289,208,294);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out11, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out12, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          ANDstate = ANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          if(ANDstate == 16){
            myGLCD.setColor(VGA_LIME);
            myGLCD.print("IC -->",577,260);
            myGLCD.print(" OK ",688,260);
          }
          else{
            myGLCD.setColor(VGA_RED);
            myGLCD.print("IC -->",577,260);
            myGLCD.print("Fail",688,260);
          }
          myGLCD.setBackColor(32,32,228);
          Serial.print(ANDstate);
    break;
    
    case 2: // Ejecuta test a compuerta OR
            // Entrada 0 y 0 en GATE 1
        Serial.print(" en GATE OR ");
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.print("GATE 1",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(53,418,58,364);
        myGLCD.fillRect(59,364,133,368);
        myGLCD.fillRect(117,418,122,383);
        myGLCD.fillRect(123,383,133,387);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out1, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out2, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read1 = digitalRead(out3);
        read2 = analogRead(out3);
        Serial.print("digital READ   ");
          Serial.print(read1);
          Serial.print("   Analog READ   ");
          Serial.println(read2);
        if(read1 ==HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out1, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out2, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
           read1 = digitalRead(out3);
           read2 = analogRead(out3);
          Serial.print("digital READ   ");
          Serial.print(read1);
          Serial.print("   Analog READ   ");
          Serial.print(read2);
          if(read1 ==HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(53,418,58,364);
           myGLCD.fillRect(59,364,133,368);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out1, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out2, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(53,418,58,364);
           myGLCD.fillRect(59,364,133,368);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out1, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out2, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(179,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
        delay(1000);

        
               // Entrada 0 y 0 en GATE 2
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 2",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(264,418,269,364);
        myGLCD.fillRect(270,364,352,369);
        myGLCD.fillRect(336,418,341,383);
        myGLCD.fillRect(342,383,355,387);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out4, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out5, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read2 = digitalRead(out6);
        if(read2 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out4, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out5, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(264,418,269,364);
           myGLCD.fillRect(270,364,352,369);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out4, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out5, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(264,418,269,364);
           myGLCD.fillRect(270,364,352,369);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out4, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out5, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(400,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
         delay(1000);
         
          // Entrada 0 y 0 en GATE 3
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 3",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(412,254,417,269);
        myGLCD.fillRect(395,264,413,269);
        myGLCD.fillRect(395,269,399,293);
        myGLCD.fillRect(400,288,414,293);
        myGLCD.fillRect(339,254,344,312);
        myGLCD.fillRect(345,307,414,312);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out8, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out9, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read3 = digitalRead(out7);
        if(read3 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out8, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out9, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(412,254,417,269);
           myGLCD.fillRect(395,264,413,269);
           myGLCD.fillRect(395,269,399,293);
           myGLCD.fillRect(400,288,414,293);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out8, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out9, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(412,254,417,269);
           myGLCD.fillRect(395,264,413,269);
           myGLCD.fillRect(395,269,399,293);
           myGLCD.fillRect(400,288,414,293);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out8, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out9, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(466,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

delay(1000);
         
          // Entrada 0 y 0 en GATE 4
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 4",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(191,254,196,292);
        myGLCD.fillRect(192,289,208,294);
        myGLCD.fillRect(115,254,120,311);
        myGLCD.fillRect(117,307,208,312);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out11, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out12, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read4 = digitalRead(out10);
        if(read4 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out11, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out12, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(191,254,196,292);
           myGLCD.fillRect(192,289,208,294);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out11, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out12, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(191,254,196,292);
           myGLCD.fillRect(192,289,208,294);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out11, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out12, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 >=HIGH){
          ORstate = ORstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(253,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
         if(ORstate == 12){
            myGLCD.setColor(VGA_LIME);
            myGLCD.print("IC -->",577,260);
            myGLCD.print(" OK ",688,270);
          }
          else{
            myGLCD.print("IC -->",577,260);
            myGLCD.print("Fail",688,260);
          }
          
          myGLCD.setBackColor(32,32,228);
    break;

case 3: // Ejecuta test a compuerta NOT
            // Entrada 0 en GATE 1
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 1",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(53,418,58,364);
        myGLCD.fillRect(59,364,69,368);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out1, LOW);
        myGLCD.print("0",615,100);
        delay(1000);
        read1 = digitalRead(out2);
        if(read1 ==HIGH){
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(114,364,122,368);
          myGLCD.fillRect(118,369,122,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(114,364,122,368);
          myGLCD.fillRect(118,369,122,418);
          }
          // Entrada 1 en GATE 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(53,418,58,364);
           myGLCD.fillRect(59,364,69,368);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out1, HIGH);
           myGLCD.print("1",615,140);
           delay(1000);
           read1 = digitalRead(out2);
          if(read1 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(114,364,122,368);
          myGLCD.fillRect(118,369,122,418);
          }
          else{
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(114,364,122,368);
          myGLCD.fillRect(118,369,122,418);
          }
        delay(1000);
        
               // Entrada 0 en GATE 2
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);       
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 2",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(190,418,195,364);
        myGLCD.fillRect(196,364,210,369);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out3, LOW);
        myGLCD.print("0",615,100);
        delay(1000);
        read2 = digitalRead(out4);
        if(read2 ==HIGH){
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(257,364,267,369);
          myGLCD.fillRect(263,370,267,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(257,364,267,369);
          myGLCD.fillRect(263,370,267,418);
          }
          
          // Entrada 1 en GATE 2
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(190,418,195,364);
           myGLCD.fillRect(196,364,210,369);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out3, HIGH);
           myGLCD.print("1",615,140);
           delay(1000);
        read2 = digitalRead(out4);
        if(read2 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(257,364,267,369);
          myGLCD.fillRect(263,370,267,418);
          }
          else{
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(257,364,267,369);
          myGLCD.fillRect(263,370,267,418);
          }
delay(1000);
         
          // Entrada 0 en GATE 3
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);       
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 3",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(337,418,341,364);
        myGLCD.fillRect(342,364,355,368);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out5, LOW);
        myGLCD.print("0",615,100);
        delay(1000);
        read4 = digitalRead(out6);
        if(read4 ==HIGH){
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(400,364,415,368);
          myGLCD.fillRect(411,369,415,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(400,364,415,368);
          myGLCD.fillRect(411,369,415,418);
          }
          // Entrada 1 en GATE 3
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(337,418,341,364);
           myGLCD.fillRect(342,364,355,368);
           myGLCD.setColor(VGA_LIME);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out5, HIGH);
           myGLCD.print("1",615,140);
           delay(1000);
        read4 = digitalRead(out6);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(400,364,415,368);
          myGLCD.fillRect(411,369,415,418);
          }
          else{
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(400,364,415,368);
          myGLCD.fillRect(411,369,415,418);
          }

delay(1000);
         
          // Entrada 0 en GATE 4
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);       
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 4",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(412,254,417,301);
        myGLCD.fillRect(418,296,428,301);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out8, LOW);
        myGLCD.print("0",615,100);
        delay(1000);
        read4 = digitalRead(out7);
        if(read4 ==HIGH){
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(470,296,476,301);
          myGLCD.fillRect(471,295,476,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(470,296,476,301);
          myGLCD.fillRect(471,295,476,254);
          }
          // Entrada 1 en GATE 4
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(412,254,417,301);
           myGLCD.fillRect(418,296,428,301);
           myGLCD.setColor(VGA_LIME);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out8, HIGH);
           myGLCD.print("1",615,140);
           delay(1000);
        read4 = digitalRead(out7);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(470,296,476,301);
          myGLCD.fillRect(471,295,476,254);
          }
          else{
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(470,296,476,301);
          myGLCD.fillRect(471,295,476,254);
          }

delay(1000);
         
          // Entrada 0 en GATE 5
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);       
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 5",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(264,254,269,301);
        myGLCD.fillRect(270,296,285,301);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out10, LOW);
        myGLCD.print("0",615,100);
        delay(1000);
        read4 = digitalRead(out9);
        if(read4 ==HIGH){
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(328,296,336,301);
          myGLCD.fillRect(337,301,342,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(328,296,336,301);
          myGLCD.fillRect(337,301,342,254);
          }
          // Entrada 1 en GATE 5
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(264,254,269,301);
           myGLCD.fillRect(270,296,285,301);
           myGLCD.setColor(VGA_LIME);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out10, HIGH);
           myGLCD.print("1",615,140);
           delay(1000);
        read4 = digitalRead(out9);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(328,296,336,301);
          myGLCD.fillRect(337,301,342,254);
          }
          else{
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(328,296,336,301);
          myGLCD.fillRect(337,301,342,254);
          }

delay(1000);
         
          // Entrada 0 en GATE 6
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);       
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 6",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(115,254,120,301);
        myGLCD.fillRect(121,296,135,301);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out12, LOW);
        myGLCD.print("0",615,100);
        delay(1000);
        read4 = digitalRead(out11);
        if(read4 ==HIGH){
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(177,296,190,301);
          myGLCD.fillRect(191,301,195,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(177,296,190,301);
          myGLCD.fillRect(191,301,195,254);
          }
          // Entrada 1 en GATE 6
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(115,254,120,301);
           myGLCD.fillRect(121,296,135,301);
           myGLCD.setColor(VGA_LIME);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out12, HIGH);
           myGLCD.print("1",615,140);
           delay(1000);
        read4 = digitalRead(out11);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(177,296,190,301);
          myGLCD.fillRect(191,301,195,254);
          }
          else{
          NOTstate = NOTstate +1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(177,296,190,301);
          myGLCD.fillRect(191,301,195,254);
          }
          

         if(NOTstate == 12){
            myGLCD.setColor(VGA_LIME);
            myGLCD.print("IC -->",577,260);
            myGLCD.print(" OK ",688,260);
          }
          else{
            myGLCD.setColor(VGA_RED);
            myGLCD.print("IC -->",577,260);
            myGLCD.print("Fail",688,260);
          }
          
          myGLCD.setBackColor(32,32,228);
     break;

     case 5: // Ejecuta test a compuerta NAND
            // Entrada 0 y 0 en GATE 1
        myGLCD.setBackColor(VGA_BLACK);
        myGLCD.print("GATE 1",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(53,418,58,364);
        myGLCD.fillRect(59,364,133,368);
        myGLCD.fillRect(117,418,122,383);
        myGLCD.fillRect(123,383,133,387);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out1, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out2, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          NANDstate = NANDstate+1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out1, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out2, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          NANDstate = NANDstate+1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(53,418,58,364);
           myGLCD.fillRect(59,364,133,368);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out1, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out2, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          NANDstate = NANDstate+1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(53,418,58,364);
           myGLCD.fillRect(59,364,133,368);
           myGLCD.fillRect(117,418,122,383);
           myGLCD.fillRect(123,383,133,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out1, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out2, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read1 = digitalRead(out3);
        if(read1 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
          else{
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(172,372,193,377);
          myGLCD.fillRect(190,372,195,418);
          }
        delay(1000);

        
               // Entrada 0 y 0 en GATE 2
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 2",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(264,418,269,364);
        myGLCD.fillRect(270,364,352,369);
        myGLCD.fillRect(336,418,341,383);
        myGLCD.fillRect(342,383,355,387);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out4, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out5, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out4, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out5, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(264,418,269,364);
           myGLCD.fillRect(270,364,352,369);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out4, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out5, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(264,418,269,364);
           myGLCD.fillRect(270,364,352,369);
           myGLCD.fillRect(336,418,341,383);
           myGLCD.fillRect(342,383,355,387);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out4, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out5, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read2 = digitalRead(out6);
        if(read2 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
          else{
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(390,372,408,377);
          myGLCD.fillRect(409,372,414,418);
          }
         delay(1000);
         
          // Entrada 0 y 0 en GATE 3
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 3",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(412,254,417,269);
        myGLCD.fillRect(395,264,413,269);
        myGLCD.fillRect(395,269,399,293);
        myGLCD.fillRect(400,288,414,293);
        myGLCD.fillRect(339,254,344,312);
        myGLCD.fillRect(345,307,414,312);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out8, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out9, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out8, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out9, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){

          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(412,254,417,269);
           myGLCD.fillRect(395,264,413,269);
           myGLCD.fillRect(395,269,399,293);
           myGLCD.fillRect(400,288,414,293);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out8, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out9, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(412,254,417,269);
           myGLCD.fillRect(395,264,413,269);
           myGLCD.fillRect(395,269,399,293);
           myGLCD.fillRect(400,288,414,293);
           myGLCD.fillRect(339,254,344,312);
           myGLCD.fillRect(345,307,414,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out8, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out9, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read3 = digitalRead(out7);
        if(read3 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }
          else{
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(454,298,475,302);
          myGLCD.fillRect(472,298,477,254);
          }

delay(1000);
         
          // Entrada 0 y 0 en GATE 4
        myGLCD.setColor(VGA_BLACK);
        myGLCD.fillRect(580,95,660,260);
        myGLCD.fillRect(710,95,740,280);
        delay(500);
        myGLCD.setColor(VGA_YELLOW);
        myGLCD.print("GATE 4",577,260);
        myGLCD.setColor(VGA_LIME);
        myGLCD.fillRect(191,254,196,292);
        myGLCD.fillRect(192,289,208,294);
        myGLCD.fillRect(115,254,120,311);
        myGLCD.fillRect(117,307,208,312);
        myGLCD.setBackColor(VGA_BLACK);
        digitalWrite(out11, LOW);
        myGLCD.print("0",590,100);
        digitalWrite(out12, LOW);
        myGLCD.print("0",640,100);
        delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,100);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,100);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          // Entrada 0 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out11, LOW);
           myGLCD.print("0",590,140);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out12, HIGH);
           myGLCD.print("1",640,140);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,140);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,140);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }

          // Entrada 1 y 0
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(191,254,196,292);
           myGLCD.fillRect(192,289,208,294);
           myGLCD.setColor(VGA_LIME);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out11, HIGH);
           myGLCD.print("1",590,180);
           myGLCD.setColor(VGA_LIME);
           digitalWrite(out12, LOW);
           myGLCD.print("0",640,180);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,180);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,180);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }

          // Entrada 1 y 1
           delay(1000);
           myGLCD.setColor(VGA_RED);
           myGLCD.fillRect(191,254,196,292);
           myGLCD.fillRect(192,289,208,294);
           myGLCD.fillRect(115,254,120,311);
           myGLCD.fillRect(117,307,208,312);
           myGLCD.setColor(VGA_RED);
           digitalWrite(out11, HIGH);
           myGLCD.print("1",590,220);
           digitalWrite(out12, HIGH);
           myGLCD.print("1",640,220);
           delay(1000);
        read4 = digitalRead(out10);
        if(read4 ==HIGH){
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("1",710,220);
          myGLCD.setColor(VGA_RED);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          else{
          NANDstate = NANDstate + 1;
          myGLCD.setColor(VGA_WHITE);
          myGLCD.print("0",710,220);
          myGLCD.setColor(VGA_LIME);
          myGLCD.fillRect(247,298,267,303);
          myGLCD.fillRect(262,254,267,297);
          }
          if(NANDstate == 16){
            myGLCD.setColor(VGA_LIME);
            myGLCD.print("IC -->",577,260);
            myGLCD.print(" OK ",688,260);
          }
          else{
            myGLCD.setColor(VGA_RED);
            myGLCD.print("IC -->",577,260);
            myGLCD.print("Fail",688,260);
          }
          myGLCD.setBackColor(32,32,228);
          Serial.print(NANDstate);
    break;
  
 < }
}

This is a new project in development, therefore, only the system can test AND, OR, NOT and NAND IC Gates. Soon I will update the Sketch with the functionality for the remaining gates.

Categories



Maker Pro Logo
Continue to site
Quote of the day

-