0

Problem using TFT and RX-TX at the same time
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Problem using TFT and RX-TX at the same time

by ArmanH on Sun Sep 27, 2020 7:35 pm

Dear all,

I am using an Adafruit 1947 capacitive TFT touch screen which I mounted on an Uno. I also have a Nano 33 BLE, which is connected to a sensor. I want to control a condition with the touch panel. For that, I coded the Nano to give the output to Serial1. I checked with bare Uno and it was able to communicate well with Nano. But the problem arises when I connect the TFT screen to the Uno. In that case, the Nano still sends the correct values, but the Uno gives the wrong number.

Any ideas?

PS: I have connected the two boards as described on http://thezhut.com/?page_id=1437, using resistors. I am turning on both by connecting to my PC. Long story short, Uno receives data fine w/o TFT, but when TFT is installed, it mixes up.

ArmanH
 
Posts: 3
Joined: Sun Sep 27, 2020 7:35 pm

Re: Problem using TFT and RX-TX at the same time

by adafruit_support_bill on Sun Sep 27, 2020 7:40 pm

Please post the code you are using.

adafruit_support_bill
 
Posts: 81903
Joined: Sat Feb 07, 2009 10:11 am

Re: Problem using TFT and RX-TX at the same time

by ArmanH on Sun Sep 27, 2020 7:44 pm

adafruit_support_bill wrote:Please post the code you are using.

My code should be fine; as the Uno alone is able to communicate, but the problem arise when the TFT shield is installed. But here it is:

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_GFX.h>         // Core graphics library
#include <SPI.h>       // this is needed for display
#include <Adafruit_ILI9341.h>     // Hardware-specific library
#include <Wire.h>      // this is needed for FT6206
#include <Adafruit_FT6206.h>
#include <SdFat.h>                // SD card & FAT filesystem library
#include <Adafruit_ImageReader.h> // Image-reading functions
#define SD_CS   4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC  9 // TFT display/command pin
SdFat                SD;         // SD card filesystem
Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
Adafruit_ILI9341     tft    = Adafruit_ILI9341(TFT_CS, TFT_DC);
Adafruit_FT6206 ctp = Adafruit_FT6206();
Adafruit_Image       img;        // An image loaded into RAM
int32_t              width  = 0, // BMP image dimensions
                     height = 0;
int proximity;

void setup(void) {
  Serial.begin(9600);
  ImageReturnCode stat; // Status from image-reading functions
  tft.begin();          // Initialize screen
  ctp.begin(40);        // pass in 'sensitivity' coefficient
  SD.begin(SD_CS, SD_SCK_MHZ(25));
  tft.fillScreen(ILI9341_WHITE);
  stat = reader.drawBMP("/Test.bmp", tft, 170, 6);
  reader.printStatus(stat);
  tft.setCursor(6 , 6);
  tft.setTextColor(ILI9341_BLACK);
  tft.setTextSize(1);
  tft.println("Battery: 100%");
  tft.fillRect(56, 120, 128, 32, ILI9341_ORANGE);
  tft.setCursor(64 , 128);
  tft.setTextColor(ILI9341_BLUE);
  tft.setTextSize(2);
  tft.println("Disinfect!");
  tft.setCursor(88 , 240);
  tft.setTextColor(ILI9341_BLACK);
  tft.setTextSize(1);
  tft.println(__DATE__);
  tft.setCursor(88 , 272);
  tft.setTextColor(ILI9341_BLACK);
  tft.setTextSize(1);
  tft.println(__TIME__);
}

void loop() {
  if (! ctp.touched()) {
    return;
  }
  TS_Point p = ctp.getPoint();
  p.x = map(p.x, 0, 240, 240, 0);
  p.y = map(p.y, 0, 320, 320, 0);
  if (56 < p.x && p.x < 184 && 120 < p.y && p.y < 152) {
    Serial.available();
    proximity = Serial.read();
        tft.setCursor(6 , 180);
        tft.setTextColor(ILI9341_RED);
        tft.setTextSize(2);
        tft.println(proximity);
        delay(3000);
    if (proximity < 150){
      for (int i=10; 0<i; i--) {
        tft.setCursor(112 , 180);
        tft.setTextColor(ILI9341_RED);
        tft.setTextSize(3);
        tft.println(i);
        delay(1000);
        tft.fillRect(112, 180, 48, 24, ILI9341_WHITE);
      }
    }
    else {
        tft.setCursor(6 , 180);
        tft.setTextColor(ILI9341_RED);
        tft.setTextSize(2);
        tft.println("Status: Not secured");
        delay(3000);
        tft.fillRect(6, 180, 228, 48, ILI9341_WHITE);
    }
  }
}

ArmanH
 
Posts: 3
Joined: Sun Sep 27, 2020 7:35 pm

Re: Problem using TFT and RX-TX at the same time

by adafruit_support_bill on Mon Sep 28, 2020 6:04 am

My code should be fine; as the Uno alone is able to communicate,

Without the shield you will not be executing all the memory and processor intensive parts of the code posted. You need to pare down the code the the minimum subset that causes things to break. Try running just the communication code with the shield installed. If there are still communication issues, please post the specifics.

adafruit_support_bill
 
Posts: 81903
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.