Hello All,
I am a new member here and have started playing with Arduino about a week ago. What an amazing piece of equipment! Anyway, I purchased a SainSmart 1.8" TFT LCD and am having some interesting issues. I've done some research (on both Google and here) but despite having found similar situations, I haven't been able to find anything that has nipped this in the butt yet. I don't believe the issue is with the LCD itself, but I'm hoping someone can point me in the right direction.
Here's my setup:
An Arduino UNO R3
A SainSmart 1.8" TFT LCD
A DS18B20 OneWire Digital Temperature Sensor
What I Am Trying To Do:
I want to take the ambient room temperature and display it on the screen. This I have working via SPI and it works beautifully when plugged into USB (that is through a computer). When utilizing a power source such as an iPhone charger through USB, the issue below occurs.
Here is an image of the screen working with USB Power through a computer: Through USB on Comp.jpg - Google Drive
Please fullscreen these images in the google docs viewer to see the pixels. Sorry it's really hard to convey this issue through pictures, but I chose the initialization screen because it's easiest to see the flaws.
What Is The Problem?
When I plug into external power, the screen flickers and the display seems to "bleed" some of the colors except for when text is updated. If I hold down the reset button, it stops flickering. I'm not sure what I'm doing wrong, but I'm sure that it's me and not the hardware. My gut tells me it could be that the power from these bricks isn't "clean" enough, but I'm no electrical engineer so please excuse my ignorance on the subject.
Here is a picture of the display on external power: Through External Power.JPG - Google Drive
Again it's tough to show but perhaps you can see the "bleed" I am describing trailing down the screen from the text. Accompanying this trail is a noticeable flicker that seems to be irregular in pattern, like some sort of unstable timing issue.
The Sketch (With beginning credits cut out for brevity):
//Temp IC Libraries
#include <OneWire.h>
#include <DallasTemperature.h>
//Temperature Sensor Data Wire is Plugged into pin 2 on Arduino
#define ONE_WIRE_BUS 2
//Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
//Pass oneWire reference to Dallas Temperature
DallasTemperature sensors(&oneWire);
//define TFT connections
//#define sclk 13
//#define mosi 11
#define cs 10
#define dc 9
#define rst 8
//Include Necessary Libraries
//TFT Libraries
#include <SPI.h>
#include <Adafruit_ST7735.h>
#include <Adafruit_GFX.h>
//Initialize SPI
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
void setup(void) {
tft.initR(INITR_BLACKTAB); //initialize a ST7736S chip, black tab
delay(500);
//make background white
tft.fillScreen(0xFFFF);
delay(100);
//Show some startup text
startuptext();
//Start up the temperature library
sensors.begin();
//make screen black and set text colors for next procedure
tft.fillScreen(0x0000);
tft.setTextColor(0xFFFF,0x0000);
}
int i=0;
void loop(void) {
//print temperature readings 5 times
for (i;i<5;i++) {
tft.setCursor(30,73);
//Print Temp to LCD
temperature();
tft.print("Temp: ");
tft.print(sensors.getTempFByIndex(0));
tft.print(" F");
}
}
void temperature() {
//call sensors.requestTemperatures() to issue a global temperature request
sensors.requestTemperatures(); //Send the command to get temperatures
}
void startuptext() {
tft.setTextWrap(true);
tft.fillScreen(0xEE07);
tft.setCursor(20,20);
tft.setTextColor(0x0000);
tft.setTextSize(1);
tft.println("Initializing...");
tft.setCursor(18,120);
tft.println("Please Stand By");
delay(1000);
}
Thanks for your help in advance!