TFTshield : how to RESET pin? (#define LCD_RESET A4->RST?)

Hi,

I have this http://www.ebay.com/itm/390631788477?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649 TFT display (spfd5408 controller) on my Duemilanove 168 with sensorshield.

// optional
#define LCD_RESET A4

Because I need the A4 pin for a sensor, how can I comment out #define LCD_RESET A4 , it is labeled as "optional". What does it by optional? Otherwise how can I "connect directly to arduinos RESET"?

btw its a pretty display for low budget. Is it possible to draw some simple interactive 3d graphics on it?

thank you.

I don't see how or even why you would want to connect the reset pin on the LCD to the reset pin of your Arduino. Since this is a shield, you can't remap the pins. You won't be able to use the freed up pin anyway if you could, so I don't see the point.

#define LCD_RESET A4 simply lets you refer to A4 by using LCD_RESET, you can think of it as a label. (Just a little FYI, A4 is a #define of an actual numeric value) So it doesn't really matter what 'label' you use.

TheCoolest:
I don't see how or even why you would want to connect the reset pin on the LCD to the reset pin of your Arduino. Since this is a shield, you can't remap the pins. You won't be able to use the freed up pin anyway if you could, so I don't see the point.

my setup is: aruino + sensorshield v4 + TFT display. the sensorshield has sideconnectors Its only a testproject for a short TFT demonstration + one I2C sensor (therefore I need A4 and A5).

How does "#define LCD_RESET" works. what does it make with the display?. If I define LCD_RESET 0 , then the display stays white, so why is it optional? I'm using #include "TFTLCD.h" #include "TouchScreen.h" with examplesketch:

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0 
// optional
#define LCD_RESET A4

The adafruit TFTLCD library doesnt work with my display, but it says:

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

The point of it being "optional" is that you can just use A4 instead of LCD_RESET.
Read up on the #define directive in C/C++ to understand how it works and what it is usually used for, maybe then it'll be clear.
I don't see a "simple" way of changing pins, since you have shields, PCBs where each pin on your Arduino is hardwired to a specific pin on the LCD. The only way for you to use another pin is to make physical modifications to your shields.

Hi Samond,

Which library are you using with that display? You say the Adafruit library doesn't work, but you don't say which one you're using.

You could always unsolder that reset pin from the TFT shield and run a separate wire to the Arduino's reset line.

The library is based on adafruits one, but without the bitmapexamples and the code looks a little different. actually I got this file from the seller and its a combination of TFTLCD.h and TouchScreen.h

today the seller send me a funny msg, saying that following the productdescription I can use A4 but I cant :slight_smile:

TFTLCD.zip (18.3 KB)

now Im trying one week to get this working :slight_smile:

library:
https://github.com/adafruit/TFTLCD-Library/blob/master/examples/tftpaint/tftpaint.pde

and here adafruit writes:
Connect the seventh pin RST (Reset) to the Arduino Reset line. This will reset the panel when the Arduino is Reset. You can also use a digital pin for the LCD reset but this will save us a pin.

now my code is

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0 
// optional
#define LCD_RESET RST

and I get:

tftpaint:43: error: ‘RST’ was not declared in this scope


pin2 seems to be free, so I set it HIGH and wired with the resetpin from the shield. and the screen stays white.

who can help me, pls!?

The TFT reset has nothing whatsoever to do with the backlight. The backlight is either directly powered from Vcc or from a PWM pin (depending on whether it is PWM capable, or whether that line is even brought out to where you can connect to it). The Reset function resets the controller chip, something that has do be done during startup of the screen. It can either be handled by a software routine in the sketch, using a digital pin for that, or as a "side effect" of hitting the Arduino's reset button, but the sketch has to correctly specify one or the other. Even if you actually connect to the Arduino reset pin, you probably have to leave a #define for the reset function in the sketch, because the sketch will somewhere call upon that pin (even if not connected and not used) and will give you a "not defined in this scope" error if you've taken out the #define.

I don't recall whether the reset occurs when the pin goes low or high (probably low as that's the way most chip reset functions work). So, if you've connected to pin2, the sketch (or library that it calls) has to momentarily set that pin LOW when starting up the screen. If you define the reset as that pin in your sketch, the library should actually take care of setting it high and low as needed and you should not be setting it high.

For the moment, I'd suggest disconnecting your sensor from the pin defined as reset in the examples you are trying to run and work at getting the screen working and at understanding what's going on in those examples. It will then be easier to make the changes needed to free up that pin, either by letting the Arduino reset button handle things, or by using a different pin for the software reset.

Ciao,
Lenny

LROBBINS:
The TFT reset has nothing whatsoever to do with the backlight. The backlight is either directly powered from Vcc or from a PWM pin (depending on whether it is PWM capable, or whether that line is even brought out to where you can connect to it).

Hi lenny,
with white screen I ment white backlight and no image.

anyway, now its working more or less. the trick was to let #define LCD_RESET A4 as it is and connect the pin to the shield to arduinos reset, but LCD_RESET has to be defined for the library. So I defined it as A6 :slight_smile:

I think that at this point the best thing to do would be to read, line by line, the example that you are trying to run as well as the library *.cpp file. You must understand what they are doing, or you will not get things to work correctly. You probably CAN use pin2, if it is not being used elsewhere in the program, but you will surely have to change some #define statement(s) to do so. Ciao, Lenny

Samond, we are using the same LCD modules as I can see.
Only difference is in Arduinos - I'm using Mega 2560.

With any sketches it gives white background. Even unprogrammed it is white.
I think, the problem is not in RESET pin.

DmitryR:
Samond, we are using the same LCD modules as I can see.
Only difference is in Arduinos - I'm using Mega 2560.

With any sketches it gives white background. Even unprogrammed it is white.
I think, the problem is not in RESET pin.

Did you try the library I posted? It looks similar to adafruits TFTLCDlib , but its not. And D2 and D3 is actually needed on this shield.
On both, Due and Uno, the shield works.

Look at my suggestions here: http://pastebin.com/Jn1iyQij
The D2 pin is used for the SD card slot, unless you need the SD card slot, you can use that pin freely.

Samond, yes - I used the library you posted, but still no result.
Could you post here, how the pins are connected, and what code exactly (with libs) are you usung?

I still can't figure out, where's my problem. Where do the pins "LCD_Dx" connect to? Can I just connect the board directly to my Mega?

TheCoolest - I've tried your suggestion, but still no result.

#include "TFTLCD.h"
#include "TouchScreen.h"


//Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:



#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM  7 // can be a digital pin
#define XP  6  // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0 
// optional. (optional means, that you can just connect the LCD_RESET pin to the RESET of your arduino. it works, without changing the code. I need the A4 pin, so I changed this to #define LCD_RESET A6 , because it has to have a value and there are no pins left. it works like this.
#define LCD_RESET A4

// Color definitions
#define	BLACK           0x0000
#define	BLUE            0x001F
#define	RED             0xF800
#define	GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0 
#define WHITE           0xFFFF



TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
  Serial.begin(9600);
  Serial.println("Paint!");
  
  tft.reset();
  
  uint16_t identifier = tft.readRegister(0x0);


  tft.initDisplay(); 
  tft.fillScreen(BLACK);
  
  tft.fillRect(0, 320-BOXSIZE, BOXSIZE, 320,MAGENTA );
  tft.fillRect(BOXSIZE, 320-BOXSIZE, BOXSIZE, 320,BLUE );
  tft.fillRect(BOXSIZE*2, 320-BOXSIZE, BOXSIZE, 320,CYAN );
  tft.fillRect(BOXSIZE*3, 320-BOXSIZE, BOXSIZE, 320, GREEN);
  tft.fillRect(BOXSIZE*4, 320-BOXSIZE, BOXSIZE, 320, YELLOW);
  tft.fillRect(BOXSIZE*5, 320-BOXSIZE, BOXSIZE, 320, RED);
 // tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, WHITE);
 
// tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
 currentcolor = RED;
 
  pinMode(13, OUTPUT);
}



#define MINPRESSURE 10
#define MAXPRESSURE 1000



void loop()
{
  digitalWrite(13, HIGH);
  Point p = ts.getPoint();
  digitalWrite(13, LOW);


  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //pinMode(YM, OUTPUT);

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {

    
    if (p.y < (TS_MINY-5)) {
      Serial.println("erase");
     // press the bottom of the screen to erase 
      tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
      
    }
    // turn from 0->1023 to tft.width
    p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);

    if (p.y < BOXSIZE) {
       oldcolor = currentcolor;
 
  
       if (p.x < BOXSIZE) { 
         currentcolor = RED; 
      //   tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
       } 
       else if (p.x < BOXSIZE*2) {
         currentcolor = YELLOW; 
       //  tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*3) {
         currentcolor = GREEN; 
       //  tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*4) {
         currentcolor = CYAN; 
      //   tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*5) {
         currentcolor = BLUE; 
   //      tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*6) {
         currentcolor = MAGENTA; 
       //  tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       
      // if (oldcolor != currentcolor) {
     //     if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE,MAGENTA );
    //      if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE,BLUE );
    //      if (oldcolor == GREEN) tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE,CYAN );
    //      if (oldcolor == CYAN) tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, GREEN);
    //      if (oldcolor == BLUE) tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, YELLOW);
    //      if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, RED);
     //  }
    }
    if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
      tft.fillCircle(240-p.x, 320-p.y, PENRADIUS, currentcolor);
    }
  }
}

this code is working with my arduino due and uno, if i use the shield. the library is TFTLCD (posted).

there is one seller on ebay writing that this shield doesnt work with mega, because of different pins! so test it with an uno, if you can. good luck!

Thanks, Samond!

I also saw this info from another seller. But when I purchased this module - it was told that Mega is also supported.
Will see if it's possible to do something on Mega with it :slight_smile:

Still the same white screen.

I've found some info about pin differences between UNO and Mega,
that LCD_D0 ... LCD_D7 should be connected to pins 22 ... 29, not to 2 ... 9 on Mega.

Can anyone say, if it is really so?

i had this problem too!what can i do!!!!

I have the same issue on Arduino Uno, I bought this LCD touch 2,4 tft and it wants 5 analog pins while on Uno board I have only 6 of them and 2 are needed for RTC module which uses analog pins too. I defined LCD_RESET=A6, connected LCD_RST to RESET pin on board and i have white screen, when I connect the wire to A4 everything works.

Update:
Ahh! yes it worked !!! I connected LCD_RESET to digital 10 pin and defined LCD_RESET = 10. Everything seems to work or I did something wrong ?

you can just wire lcd A4 to lcd reset pin and break the pin goes arduino A4 and use arduinos a4 as u wish.