Go Down

Topic: Can the Sainsmart 3.2" TFT be turned on & off? (Read 3 times) previous topic - next topic


Hello all,
I bought a Mega2560 with the 3.2" Touch screen and shield from Sainsmart to build a vehicle battery monitor. Everything has worked amazingly well and with all of the info and code libraries around getting most things running has been fairly quick and easy! However, since this monitor will run 24/7, I'm concerned about the lifetime of the touchscreen and backlight. Does anyone know of a way to turn this screen off & on? The .lcdOff() and .lcdOn() functions don't work with this model. Even a hardware mod would be acceptable. :-)
cheers, Bernie


A p-channel MOSFET to switch the Vcc input to the LCD?

You'd have to ensure all the signal lines were low or INPUT before powering it down.  For instance
the IRL5602S is a logic-level p-channel device.
[ I won't respond to messages, use the forum please ]


Dec 25, 2012, 03:48 am Last Edit: Dec 25, 2012, 04:01 am by guix Reason: 1
Hello and welcome :)

I modified the UTFT library like this. It is the turn on/off sequences, as described in the SSD1289 datasheet. It works, but does not control the backlight. Better than nothing :)

Code: [Select]

void UTFT::lcdOff()
cbi( P_CS, B_CS );
switch ( display_model )
case PCF8833:
LCD_Write_COM( 0x28 );

//I added this ------------------------
case SSD1289:
//turn OFF
LCD_Write_COM_DATA( 0x07,0x0000 );
LCD_Write_COM_DATA( 0x00,0x0000 );
LCD_Write_COM_DATA( 0x10,0x0001 );

//only standby mode ON: no visible difference?
//LCD_Write_COM_DATA( 0x10, 0x0001 );
sbi(P_CS, B_CS);

void UTFT::lcdOn()
cbi( P_CS, B_CS );
switch ( display_model )
case PCF8833:
LCD_Write_COM( 0x29 );

//I added this ------------------------
case SSD1289:
//turn ON
LCD_Write_COM_DATA( 0x07, 0x0021 );
LCD_Write_COM_DATA( 0x00, 0x0001 );
LCD_Write_COM_DATA( 0x07, 0x0023 );
LCD_Write_COM_DATA( 0x10, 0x0000 );
LCD_Write_COM_DATA( 0x07, 0x0033 );
LCD_Write_COM_DATA( 0x11, 0x60B0 );
LCD_Write_COM_DATA( 0x02, 0x0600 );
LCD_Write_COM( 0x22 );

//only standby mode OFF: no visible difference?
//LCD_Write_COM_DATA( 0x10, 0x0000 );
sbi( P_CS, B_CS );

Look here: http://arduino.cc/forum/index.php?topic=125856.0 . If you do the hardware modification described in this topic, please report if it worked for you :)

PS, I have exactly the same display, do you also have about 1 to 2mm slack at the left side, that you have to press to get uniform lighting?


Dec 25, 2012, 02:54 pm Last Edit: Dec 25, 2012, 02:56 pm by berniew Reason: 1
Happy Christmas (athiests and all ;) ) and thanks for the replies.
A MOSFET might work.. thanks for the suggestion.
I'll investigate guix's code and minor hardware hack first since it's less "invasive".

Actually, a combination of both suggestions might give "fade" control: I wonder if a FET-based circuit could be used to replace the pot..?
Perhaps later.

>>PS, I have exactly the same display, do you also have about 1 to 2mm slack at the left side, that you have to press to get uniform lighting?
You mean physically put pressure on the edge of the display nearest the 40-pin conn?
... I looked closely and I can see that edge is raised about 0.5mm above the PCB.. perhaps by the flexible flat-ribbon that bends around beneath it.
I can press this gently down at each corner and it extinguishes the light that seeps out from beneath.
In my case it doesn't have any visible effect on the screen lighting however.
In the attached photo, you can see that the plastic frame around the display is intended to locate into the small hole on the PCB.
Perhaps holding each corner down after applying a small drop of CA glue (a.k.a. Superglue) might help if it affects the lighting on your display?
thanks again,


If this is the setup with the mid-board with a multi turn pot for the backlight all you need to do is pop a PNP transistor in the place of the pot controlled from a PWM source, it's also not a bad idea to rig up a separate 3.3v supply too, as if you plug the board into a Arduino mega1280 it wont do the FTDI chip any good :)


Thanks beige,
I thought of using a FET because the response might be more linear and wouldn't load the PWM line?

>>pop a PNP transistor in the place of the pot controlled from a PWM source
I'm not overly skilled in analog electronics, but I thought NPN would work. Collector connected to +ve 3.3V, Emitter to the backlight control line (pot removed) and Base to the PWM output via a 1K resistor.
.. it didn't work  :(
regards, Bernie


Mine has the same problem.

It appears someone has removed the TFT cover to flip over the navigation panel ( the same display is available with icons in that area ). I guess the gap is a result of dismantling the display.

You could make a frame of electrical tape around the display to tightly hold it down.


Dec 26, 2012, 07:12 am Last Edit: Dec 26, 2012, 07:42 am by berniew Reason: 1
Some progress.
Thanks to all, I have a simple mod that allows me to control the backlight (on/off only, no fancy fading) using a spare digital output pin.
The transistor is necessary because the backlight draws close to 100mA. The digital outputs can source (or sink) a maximum of 40mA. There could be tears..
Remove the trimpot, solder 1 x PNP transistor and 1 x resistor (nominally 1K)
In the attached circuit diag and code example, I've used digital pin 8 to control the backlight.

Software still isn't entirely resolved, though I have a simple workaround.
I'd like to use guix's UTFT library mod, but it doesn't seem to toggle pin 8.
I don't yet know enough about writing to these port registers to change it nor can I find good docs about port/pin mappings.
( I WILL fix this because it's a better way to do this).
For the moment though, I left guix's library mods in place (they seem to shut down the display, though not the backlight) and added a line in my arduino sketch immediately after the call to turn the LCD on or off.
Code: [Select]

       const int backlight_pin = 8;
       const int backlight_on = 0;
       const int backlight_off = 255;


        analogWrite(backlight_pin, backlight_on);         


        analogWrite(backlight_pin, backlight_off);         


I've created a new thread that describes how to fade and control the backlight because although the info came from this thread, it's actually a slightly different subject to controling the display and modifying the UTFT library.
It's here.
cheers, Bernie


yeah,good info to me ,I'm not overly skilled in analog electronics, but I thought NPN would work.thanks for your sharing.


Nicely done, sorry I wasn't a bit clearer, was suffering from the 25th...


No worries, beige and kerryjosper. It ended up being exactly what beige suggested. The only improvement to this might be a FET instead of the transistor, as suggested by MarkT.

Go Up