Problem With LED TFT Touchscreen Toggle System

I am working on a project with a mega 2560, LCD screen, and LEDs. I am trying to create a system in which I can turn LED light strips on and off using a touchscreen. I wired everything up and created the code for the system but it's not seeming to work. Because my lights are 12v, I chose to run a separate 12v power source to power the lights and MOSFETs to control the lights by sending a 5v signal to the gate pin of the MOSFET and turn the lights on or off. But when I turn the external power source on, the lights just turn on and don't respond to the input from the touchscreen.

Here is the wiring diagram for my project:

Here is the code for my project:

#include <UTFT.h>
#include <URTouch.h>


UTFT myGLCD(ILI9341_16,38,39,40,41);
URTouch myTouch(6,5,4,3,2);

extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

int x,y;

void drawHomeScreen(){
  myGLCD.setBackColor(0,0,0);
  myGLCD.setColor(255,255,255);
  myGLCD.setFont(BigFont);
  myGLCD.print("Light Controls", CENTER, 10);

  //button set 1
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(270,40,310,80);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(270,40,310,80);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(16,167,103);
  myGLCD.print("Off",278,54);
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(220,40,260,80);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(220,40,260,80);
  myGLCD.print("On",232,54);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(0,0,0);
  myGLCD.print("Longboard Storage",30, 52);

  //button set 2
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(270,90,310,130);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(270,90,310,130);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(16,167,103);
  myGLCD.print("Off",278,102);
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(220,90,260,130);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(220,90,260,130);
  myGLCD.print("On",232,102);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(0,0,0);
  myGLCD.print("Misc Storage", LEFT, 102);

  //button set 3
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(270,140,310,180);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(270,140,310,180);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(16,167,103);
  myGLCD.print("Off",278,152);
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(220,140,260,180);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(220,140,260,180);
  myGLCD.print("On",232,152);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(0,0,0);
  myGLCD.print("Middle Shelf", CENTER, 152);

  //button set 4
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(270,190,310,230);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(270,190,310,230);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(16,167,103);
  myGLCD.print("Off",278,202);
  myGLCD.setColor(16,167,103);
  myGLCD.fillRoundRect(220,190,260,230);
  myGLCD.setColor(255,255,255);
  myGLCD.drawRoundRect(220,190,260,230);
  myGLCD.print("On",232,202);
  myGLCD.setFont(SmallFont);
  myGLCD.setBackColor(0,0,0);
  myGLCD.print("Upper Shelf", CENTER, 202);
}

void setup() {
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);

  drawHomeScreen();

}

void loop() {
  if (myTouch.dataAvailable()){
    myTouch.read();
    x=myTouch.getX();
    y=myTouch.getY();

    if ((x>=270) && (x<=310) && (y>=40) && (y<=80)){
      digitalWrite(13,LOW);
    }
    if ((x>=220) && (x<=260) && (y>=40) && (y<=80)){
      digitalWrite(13,HIGH);
    }
    if ((x>=270) && (x<=310) && (y>=90) && (y<=130)){
      digitalWrite(12,LOW);
    }
    if ((x>=220) && (x<=260) && (y>=90) && (y<=130)){
      digitalWrite(12,HIGH);
    }
    if ((x>=270) && (x<=310) && (y>=140) && (y<=180)){
      digitalWrite(11,LOW);
    }
    if ((x>=220) && (x<=260) && (y>=140) && (y<=180)){
      digitalWrite(11,HIGH);
    }
    if ((x>=270) && (x<=310) && (y>=190) && (y<=230)){
      digitalWrite(10,LOW);
    }
    if ((x>=220) && (x<=260) && (y>=190) && (y<=230)){
      digitalWrite(10,HIGH);
    }
  }
}

Here is the link to the MOSFETs I'm using:

Here is the link to the LED strips I'm using:

Does anyone have any suggestions? I could really use some help on this.

I can't see it.

Please post your code here, in code tags

Sorry about that, I just updated my original post to include my code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.