Hi, thanks for your reply. When I was about to send you an answer, it turned out that it actually works and I don't know why...
Yesterday I tried the same code with all of my screens and none worked (they were displaying only a white screen). But today (I didn't change anything about the code or the wiring) when I powered up my Arduino, the screen displayed the value of the potentiometer. I noticed that when I change the screen to test if this works, I have to do a reset of the Arduino and if I don't it doesn't work... Do you know why ? The code :
/*
Arduino TFT text example
This example demonstrates how to draw text on the
TFT with an Arduino. The Arduino reads the value
of an analog sensor attached to pin A0, and writes
the value to the LCD screen, updating every
quarter second.
This example code is in the public domain
Created 15 April 2013 by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/TFTDisplayText
*/
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst 8
// pin definition for the Leonardo
// #define cs 7
// #define dc 0
// #define rst 1
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
// char array to print to the screen
char sensorPrintout[4];
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Sensor Value :\n ", 0, 0);
// ste the font size very large for the loop
TFTscreen.setTextSize(5);
}
void loop() {
// Read the value of the sensor on A0
String sensorVal = String(analogRead(A0));
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255, 255, 255);
// print the sensor value
TFTscreen.text(sensorPrintout, 0, 20);
// wait for a moment
delay(250);
// erase the text you just wrote
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 0, 20);
}
My problem is partially solved but I still have an issue. Only one of the screen doesn't work. This screen came from a smaller box and doesn't have the green little tab on it to show the version of the screen and it might be this, but don't know what to do. Here are the two different screens (the "good" one on the left and the "bad" one on the right.
thanks a lot
Polpo