White screen on TFT only. Please, help.

Hello guys. I am trying to get this code work so I can use Android AMR_voice connected to HC-05 to get speech>text to tft screen.
All I get is a white screen and the text in Serial Monitor which just keep looping:

"Hello! ST7735 TFT TestInitialized
163
done
"
I am using 1.8 TFT SPI 128x160 with Arduino Uno and HC-05. When writing the code I was trying to combine two tutorials - Breakout Wiring & Test | 1.8" TFT Display Breakout and Shield | Adafruit Learning System and http://www.instructables.com/id/Arduino-Voice-recognition-Via-Bluetooth-HC-05/

Please, see the code below and let me know what needs to be corrected.

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <SoftwareSerial.h>


#define TFT_CS     10
#define TFT_RST    9  
#define TFT_DC     8

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

#define TFT_SCLK 13   
#define TFT_MOSI 11   


SoftwareSerial BT(1, 0); //TX, RX respetively
String voice;
char* speech;

void setup() {
 BT.begin(9600);
 Serial.begin(9600);
  Serial.print("Hello! ST7735 TFT Test");

  // Use this initializer if you're using a 1.8" TFT
  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  
  Serial.println("Initialized");

  uint16_t time = millis();
  tft.fillScreen(ST7735_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST7735_BLACK);
  tft.setTextSize(2);
  testdrawtext(speech, ST7735_WHITE);
  delay(3000);

  
  Serial.println("done");
  delay(1000);
}

//-----------------------------------------------------------------------//  
void loop() {
  while (BT.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable 
  char c = BT.read(); //Conduct a serial read
  if (c == '#') {break;} //Exit the loop when the # is detected after the word
  voice += c; //Shorthand for voice = voice + c
  }  
  if (voice.length() > 0) {
    Serial.println(voice); 

  if(voice == "*start") 
  {
    speech="Start";
  } 
  
  else if(voice == "*stop") 
  {
    speech="Stop";
  }
     

voice="";}} //Reset the variable after initiating

 
void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}

After switching "SoftwareSerial BT(1, 0);" to "SoftwareSerial BT(1,0);" I was able to type in "start" and "stop" in Serial Monitor but as soon as I connect HC-05 the screen on TFT goes to bright white. I don't know why.

hrust14:
After switching “SoftwareSerial BT(1, 0);” to “SoftwareSerial BT(1,0);” I was able to type in “start” and “stop” in Serial Monitor but as soon as I connect HC-05 the screen on TFT goes to bright white. I don’t know why.

Sorry, I meant to “(0,1)”. I was able to use AMR_voice and see output in Serial Monitor, whatever I said(without HC-05 being hooked up to Uno). As soon as I connect HC-05 the screen turned white.

Why are you trying to do SoftwareSerial on the hardware serial pins, while also doing hardware serial on those pins? That hasn't a hope in hell of working.

PaulS:
Why are you trying to do SoftwareSerial on the hardware serial pins, while also doing hardware serial on those pins? That hasn’t a hope in hell of working.

I took below code and adjusted to my TX,RX pins. Since they are connected to “0” and “1” I changed it accordingly. So what should I change so there would be a hope in hell? :slight_smile:

//Coded By: Angelo Casimiro (4/27/14)
//Voice Activated Arduino (Bluetooth + Android)
//Feel free to modify it but remember to give credit
#include <SoftwareSerial.h>

SoftwareSerial BT(11, 10); //TX, RX respetively
String voice;

void setup() {
 BT.begin(9600);
 Serial.begin(9600);
  pinMode(13, OUTPUT); 

}
//-----------------------------------------------------------------------//  
void loop() {
  while (BT.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable 
  char c = BT.read(); //Conduct a serial read
  if (c == '#') {break;} //Exit the loop when the # is detected after the word
  voice += c; //Shorthand for voice = voice + c
  }  
  if (voice.length() > 0) {
    Serial.println(voice); 

  if(voice == "*start") 
  {
    digitalWrite(13, HIGH);
  } 
  
  else if(voice == "*stop") 
  {
    digitalWrite(13, LOW);
  }
   

voice="";}} //Reset the variable after initiating

Looks as you are complicating things - troubleshooting several "problems' at once. First of all - use Serial - that one works, for debugging .

I would suggest canned Arduino example for TFT - TFTDisplayText seems to have same constructor as your Ada. But that is NO GUARANTEE it will work since the example does not specify the controller. But it may give you a start.

Once you get the TFT example to work , come back here and than we can tackle the rest.

So what should I change so there would be a hope in hell?

You need to connect the bluetooth device to some other pins, and change the arguments to the SoftwareSerial constructor to match those pins.

I used the code below and it works. It does show me all of the text and graphics. But as soon as I connect HC-05 the screen on TFT becomes so bright white that I can barely see the text and graphics. I think this is a good start to start troubleshooting but I don’t know what else to check.

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>


// For the breakout, you can use any 2 or 3 pins
// These pins will also work for the 1.8" TFT shield
#define TFT_CS     10
#define TFT_RST    9  // you can also connect this to the Arduino reset
                      // in which case, set this #define pin to 0!
#define TFT_DC     8

// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);


float p = 3.1415926;

void setup(void) {
  Serial.begin(9600);
  Serial.print("Hello! ST7735 TFT Test");

  // Use this initializer if you're using a 1.8" TFT
  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  // Use this initializer (uncomment) if you're using a 1.44" TFT
  //tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab

  Serial.println("Initialized");

  uint16_t time = millis();
  tft.fillScreen(ST7735_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST7735_BLACK);
  tft.setTextSize(2);
  testdrawtext("Hello ", ST7735_WHITE);
  delay(3000);

  
  Serial.println("done");
  delay(1000);
}

void loop() {
  tft.invertDisplay(true);
  delay(500);
  tft.invertDisplay(false);
  delay(500);
}

 
void testdrawtext(char *text, uint16_t color) {
  tft.setCursor(0, 0);
  tft.setTextColor(color);
  tft.setTextWrap(true);
  tft.print(text);
}

PaulS: You need to connect the bluetooth device to some other pins, and change the arguments to the SoftwareSerial constructor to match those pins.

I tried changing pins and SoftwareSerial constructor to match those pins, however it still doesn't work. Please, see my comment 7. I think somehow HC-05 interferes with TFT as soon as it's hooked up to Arduino.

Vaclav: Looks as you are complicating things - troubleshooting several "problems' at once. First of all - use Serial - that one works, for debugging .

I would suggest canned Arduino example for TFT - TFTDisplayText seems to have same constructor as your Ada. But that is NO GUARANTEE it will work since the example does not specify the controller. But it may give you a start.

Once you get the TFT example to work , come back here and than we can tackle the rest.

OK, let me "reverse" my position - can you disable TFT - it works ( disconnect or just in software) and test the BT module?

I assume you are "hooking it up" to more than TX/RX and NOT on pins 0,1 ( I think you changed that already - serial ports do not like to have to share devices )

I am just getting into TFT - does your really uses only "DC" as data? ( No need to answer this)

It owkrs fine with BT as I stated in comment #2. Here is the code below I used only with Serial.

#include <SoftwareSerial.h>


SoftwareSerial BT(2, 3); //TX, RX respetively
String voice;
char* speech;

void setup() {
 BT.begin(9600);
 Serial.begin(9600);
  Serial.print("Testing, 1,2,3!!!");
  Serial.println("Done!");

  }

//-----------------------------------------------------------------------//  
void loop() {
  while (BT.available()){  //Check if there is an available byte to read
  delay(10); //Delay added to make thing stable 
  char c = BT.read(); //Conduct a serial read
  if (c == '#') {break;} //Exit the loop when the # is detected after the word
  voice += c; //Shorthand for voice = voice + c
  }  
  if (voice.length() > 0) {
    Serial.println(voice); 

  if(voice == "*start") 
  {
    speech="Start";
  } 
  
  else if(voice == "*stop") 
  {
    speech="Stop";
  }
     

voice="";}} //Reset the variable after initiating

Any ideas, why BT seems to be not working together with TFT library?

Just wild guess - both devices are "timed I/O". Plain serial (pins 0 and 1 ) uses timers to send correct mark/ space using correct baud rate etc. Hitachi controller ( plain LCD) uses timers - for example the power on sequence has several timed commands etc. Most such time values generally relay on processor hardware timers. Any possibility your devices are using SAME hardware timers? The only way to find out is to check the libraries source code.