Pages: 1 [2] 3   Go Down
Author Topic: SOLVED - unable to make it work 1.8 SPI TFT 128x160  (Read 14685 times)
0 Members and 1 Guest are viewing this topic.
Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Its a 10 ohm resistor. But the LED is rated at 3.3V with a current rating of 30mA (two LEDs of 15mA in parallel). So at 30mA, the Resistor would drop 0.3V giving the LED a voltage drop of 3V which is well within spec.
Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys all your support.
I connected the LED pins, then I've tried out again the adafruit example and everything works now!

Big thanks to all of you!!!
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm glad it is working for you. And I am also glad the adafruit library works with the display so you don't have to use that awful sample code!!  smiley
Logged

~Tom~

0
Offline Offline
Newbie
*
Karma: 0
Posts: 25
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I realize this topic is months old, but I cannot get this module working.  I've hooked it up as in the original posting and all I get is a white screen.  I'm curious as to whether A0 on the lcd is actually the same as the D/C on the adafruit module and if MOSI and SDA are the same.  From what I've found online these last two are probably interchangeable.  Has anyone else gotten these to work?  I've got three of them sitting here and am at a total loss.  Thanks in advance for all the help.
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2073
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The module works fine here with adafruit's libs and following wiring (328p Uno):
SW SPI:
#define sclk 4
#define mosi 5
#define cs   6
#define dc   7
#define rst  8  

where dc=A0, mosi=SDA

HW SPI:
//#define sclk 13
//#define mosi 11
#define cs   10
#define dc   9
#define rst  8

P.
PS: my module has got a BGR color coding..
« Last Edit: January 07, 2013, 01:48:30 pm by pito » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That configuration is working perfectly to handle the TFT. What about the card reader?  smiley-razz
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello there i have just got the same TFT screen from ebay please could you tell me how you got it working and with some sample code as i'm pulling my hair out over it.
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That configuration is working perfectly to handle the TFT. What about the card reader?  smiley-razz
If using the card reader then you need to connect it to SPI. MOSI, MISO and SCK to respective lines. I used D4 for the SD Card CS. If you connect the TFT to hardware SPI too (much faster update) then what I did was connect the SD card through to hardware SPI (11, 12, 13 on UNO) and then connect the TFT SDA to the SD MOSI, TFT SCL to SD SCK, then TFT CD & AO to your defined pins.

I'll try and find time to put a more comprehensive example together of how to connect it all shortly.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That configuration is working perfectly to handle the TFT. What about the card reader?  smiley-razz
If using the card reader then you need to connect it to SPI. MOSI, MISO and SCK to respective lines. I used D4 for the SD Card CS. If you connect the TFT to hardware SPI too (much faster update) then what I did was connect the SD card through to hardware SPI (11, 12, 13 on UNO) and then connect the TFT SDA to the SD MOSI, TFT SCL to SD SCK, then TFT CD & AO to your defined pins.

I'll try and find time to put a more comprehensive example together of how to connect it all shortly.

Please do it because I'm having alot of trouble to get it to work.

Code:
#include <SD.h>
File myFile;
int cspin = 10;

void setup()
{
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
 
  if (!SD.begin(cspin)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  myFile = SD.open("test.txt", FILE_WRITE);

  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("Demotext.");
    myFile.close();
    Serial.println("done.");
  } else {
    Serial.println("error opening test.txt");
  }
   Serial.println( "Closed!");
}
 

void loop()
{
//NOP
}


I can't make this simple piece of code to work.  The LCD is disconnected but I can perfectly use it. This is how it is wired to the arduino:

SD Reader:
SCK -> 13
MISO -> 12
MOSI -> 11
CS -> 10

I'm using a stickduino with an atmega168. The memory card is a generic one with 1GB formatted with FAT. I'm using both power connections (5v to the LCD and the 3.3v of the backlight).
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2892
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Isn't the SD card 3V3? that will require an interface to work properly. There are great tutorials and sample sketches from Adafruit, I bought mine there but I can't remember about the SD card.

Bob
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't forget that

MOSI > MISO
MISO > MOSI

One devices OUT is another devices IN.

I'll do a full schematic reminder, when I get home tonight, showing exactly how to connect this up and the example code for respective pin assignments.

I did write all the connections out, with the intention of doing this last night, but some other stud came up.
« Last Edit: January 16, 2013, 04:46:51 am by tack » Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1726
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Don't forget that

MOSI > MISO
MISO > MOSI

One devices OUT is another devices IN.


No...

MOSI -> MOSI
MISO -> MISO

MOSI = "Master OUT, Slave IN"
MISO = "Master IN, Slave OUT"

The Slave devices IN pin, connects to the Master devices OUT pin, so the Slave MOSI and Master MOSI must be connected.

This is not UART, its SPI, where data moves around in a loop containing shift registers.
Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies but I've found out that the problem was due to the stickduino. I switched to an ardunino nano v3 and everything is working perfectly but now  I have another problem.

The LCD works great and so the SD card reader. But when I try to use them at the same time the LCD becomes extremely slow.  smiley-sad

Pleae take a look at this sample of code:

Code:
#define cs_lcd   10
#define cs_sd    7
#define dc       9
#define rst      8

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

Adafruit_ST7735 tft = Adafruit_ST7735(cs_lcd, dc, rst);
File myFile;

void setup()
{
  tft.initR(INITR_REDTAB);
  tft.fillScreen(ST7735_BLACK);
  tft.setTextWrap(false);
}


void loop()
{
  tft.setTextSize(5);
  tft.setTextColor(ST7735_RED, ST7735_BLACK);
  for ( int i = 0; i < 100; i++ )
  {
    tft.setCursor(40, 50);
    tft.print( i );
    delay( 100 );
  }
  
}

This sample of code works perfectly without any problem. But if I add a simple function to open and write data to a file it will start lagging severely:


Code:
#define cs_lcd   10
#define cs_sd    7
#define dc       9
#define rst      8

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

Adafruit_ST7735 tft = Adafruit_ST7735(cs_lcd, dc, rst);
File myFile;

void setup()
{
  tft.initR(INITR_REDTAB);
  tft.fillScreen(ST7735_BLACK);
  tft.setTextWrap(false);
}


void loop()
{
  tft.setTextSize(5);
  tft.setTextColor(ST7735_RED, ST7735_BLACK);
  for ( int i = 0; i < 100; i++ )
  {
    tft.setCursor(40, 50);
    tft.print( i );
    delay( 100 );
  }
  writeCard();
  
}

void writeCard()
{
  if (!SD.begin(cs_sd)) {
    //Error accessing SD CARD.
    return;
  }
  
  myFile = SD.open("tmp.txt", FILE_WRITE);
   if (myFile) {
    //WRITING TO FILE
    myFile.println("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
    // close the file:
    myFile.close();
  }  
}

I though that this could have something to do with the SS, after all I'm enabling the SD pin without disabling the LCD one but still no good.  smiley-sad-blue

Code:
void writeCard()
{
  //TRY TO DISABLE THE LCD SS PIN
  digitalWrite( cs_lcd, HIGH );
  
  if (!SD.begin(cs_sd)) {
    //Error accessing SD CARD. Re-enable LCD SS pin, force the SD SS pin to be disabled and exit.
    digitalWrite( cs_lcd, LOW );
    digitalWrite( cs_sd, HIGH );
    return;
  }
  
  myFile = SD.open("tmp.txt", FILE_WRITE);
   if (myFile) {
    //WRITING TO FILE
    myFile.println("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
    // close the file:
    myFile.close();
  }
  
  //Writing finished. Lets re-enable LCD SS pin and disable the SD SS pin.
  digitalWrite( cs_lcd, LOW );  
  digitalWrite( cs_sd, HIGH );
}


I would really love not to have to hack (aka mess with)  the Sd.h but right now I feel like I've hit a wall.

Any ideas?  smiley-sad
« Last Edit: January 18, 2013, 07:35:05 am by overflow » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, this display is compatible to the 1602 2004 LCD adapter plate IIC I2C, try to use it with the adapter on the I2C interface, as well as wanted in the beginning.
Logged

Israel
Offline Offline
Sr. Member
****
Karma: 5
Posts: 282
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, this display is compatible to the 1602 2004 LCD adapter plate IIC I2C, try to use it with the adapter on the I2C interface, as well as wanted in the beginning.

I'm sorry, but what did you just try to say?
This display isn't I2C compatible, it is already SPI enabled, there are no adapters needed to run it.
Logged


Pages: 1 [2] 3   Go Up
Jump to: