1

I want to connect the Arduino TFT LCD 1.77" screen to an Arduino Leonardo. Acording to this tutorial I should connect some pins on LCD screen to ICSP pins on Leonardo but I don't have equipment to do it. Can I just connect LCD screen to Leonardo in the way it't recommanded for an Arduino Uno (same tutorial above) using only digital and power pins. And then use sketches for Uno. Will it work?

Also, is it safe for LCD screen?

migrated from electronics.stackexchange.com Jul 18 '15 at 15:41

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

1

I think it could work, but not easily. I.e. you would need to tweak the code and anyway you will end up with really low performance.

This is the reason:

SPI: on the ICSP header. These pins support SPI communication using the SPI library. Note that the SPI pins are not connected to any of the digital I/O pins as they are on the Uno, They are only available on the ICSP connector. This means that if you have a shield that uses SPI, but does NOT have a 6-pin ICSP connector that connects to the Leonardo's 6-pin ICSP header, the shield will not work.

Source: https://www.arduino.cc/en/Main/ArduinoBoardLeonardo

The screen can be configured for use in two ways. One is to use an Arduino's hardware SPI interface. The other is to declare all the pins manually. There is no difference in the functionality of the screen between the two methods, but using hardware SPI is significantly faster when drawing. If you plan on using the SD card on the TFT module, you must use hardware SPI. All the examples are written for hardware SPI use.

Source: https://www.arduino.cc/en/Guide/TFT#toc4

In the end I think it would be better to get the equipment needed...

Edit: You can try with this constructor:

When not using hardware SPI, you can use any available pins, but you must declare the MOSI and SCLK pins in addition to CD, DC, and RESET.

#define SCLK 4
#define MOSI 5
#define CS   6
#define DC   7
#define RESET 8

TFT myScreen = TFT(CS, DC, MOSI, SCLK, RESET);

Source: https://www.arduino.cc/en/Reference/TFTLibrary

0

You can hook up the "Adafruit_ST7735" or from what i later learned after getting my Esplora. Thats when i had my adruino-epiphany. Okay so IF your wondering why im including this super rad Controller shaped arduino, the answer is, its a leonardo. well its just a different flavor of the Atmega32u4 whis is the chip that made ext serial programmers kinda obsolete and makes the uno and megas so unique as well. so with that being said the Esplora has a native language when refering back the tft libraries, but its not too far from a simple (ctrl+F) and replace Esplora references with actual defines and references. and in this case the Leonardo would need to have the icsp header used by the corresponding pins on the display (for this instance of using an SPI connection with the serial display we will not swap the Miso and Mosi like we would a nother instance.just connect miso to miso and mosi to mosi i usually plug up the whole icsp header and then that wwill leave you with the two pins you MUST DEFINE to make it work which would be :

// Pins SCLK and MOSI are fixed in hardware, and pin 10 (or 53) 

// must be an output //#define sclk 13 // for MEGAs use pin 52 //#define mosi 11 // for MEGAs use pin 51

define cs 10 // for MEGAs you probably want this to be pin 53

define dc 9

define rst 8 // you can also connect this to the Arduino reset

// Pins SCLK and MOSI are fixed in hardware, and pin 10 (or 53) 

// must be an output //#define sclk 13 // for MEGAs use pin 52 //#define mosi 11 // for MEGAs use pin 51

define cs 10 // for MEGAs you probably want this to be pin 53

define dc 9

define rst 8 // you can also connect this to the Arduino reset

// 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

include

include

// Option 1: use any pins but a little slower //ST7735 tft = ST7735(cs, dc, mosi, sclk, rst);

// Option 2: must use the hardware SPI pins // (for UNO thats sclk = 13 and sid = 11) and pin 10 must be // an output. This is much faster - also required if you want // to use the microSD card (see the image drawing example) ST7735 tft = ST7735(cs, dc, rst); float p = 3.141592; // value for pi int tft_width = 128; int tft_height = 160; int x1 = 60; int y1 = 60; int x2 = 20; int y2 = 80; int ballx = 60; int bally = 60; int deltay = 1; int deltax = 1;

int ball_speed = 24;

int left_score = 4; int right_score = 4;

int background_color = 0x00; void setup(void) { tft.initR(); // initialize a ST7735R chip

tft.writecommand(ST7735_DISPON); tft.fillScreen(background_color); delay(700); for(int i = 0; i < 9; i++){ pinMode(i,OUTPUT); } for(int i = 0; i < 9; i++){ digitalWrite(i,HIGH); } delay(500);

}

void loop() {
for(int i = 0; i < left_score; i++){ digitalWrite(i,HIGH); } for(int i = 0; i < right_score; i++){ digitalWrite(i+4,HIGH); } int cur_r = random(20,32); int cur_g = random(55,64); int cur_b = random(10,32); int color = cur_r | (cur_g << 5) | (cur_b << 11); int radius = 4; draw_paddles(); draw_ball(color); delay(ball_speed); } void draw_input_text(){ int cur_x2 = analogRead(2); int cur_y2 = analogRead(3);
String xs = String(cur_x2); String ys = String(cur_y2); char cx[4]; cx[0] = xs.charAt(0); cx[1] = xs.charAt(1); cx[2] = xs.charAt(2); cx[3] =0; char cy[4]; cy[0] = ys.charAt(0); cy[1] = ys.charAt(1); cy[2] = ys.charAt(2); cy[3] =0; tft.fillRect(10,20,40,40,background_color); tft.drawString(12,22,cx ,YELLOW); tft.drawString(12,40,cy ,YELLOW); } void draw_paddles(){ int cur_x = analogRead(0); int cur_y = analogRead(1);
int hval = 620; int lval = 350;

if ( y1 < tft_height - 20 && cur_y > hval) y1++; else if ( y1 > 0 && cur_y < lval ) y1--;

int cur_x2 = analogRead(2); int cur_y2 = analogRead(3);

if ( y2 < tft_height - 20 && cur_y2 > hval ) y2++; else if (y2 > 0 && cur_y2 < lval ) y2--; tft.fillRect(2, y1-3, 5, 27, background_color); tft.fillRect(3, y1, 3, 20, YELLOW); tft.fillRect(tft_width-3, y2-3, 5, 27,background_color); tft.fillRect(tft_width-3, y2, 3, 20, YELLOW); } void draw_ball(int color){ int bradius = 6; tft.fillCircle(ballx, bally, bradius , color); ballx += deltax; bally += deltay; if ( ballx < 7 && bally > y1 && bally < y1+20) deltax *= -1; else if ( ballx > tft_width-7 && bally > y2 && bally < y2+20) deltax *= -1; else if ( bally <= bradius || bally >= tft_height - bradius ) deltay *= -1; if (ballx <= 0 ) { left_score--; tft.drawString(2,42, "Right Won!" ,~background_color,2); tft.drawString(2,62, "Get Ready!" ,CYAN,2); for (int i = 0; i <250; i++){ delay(10); draw_paddles(); } int cur_r = random(0,26); int cur_g = random(0,30); int cur_b = random(0,18); background_color = cur_r | (cur_g << 5) | (cur_b << 11); tft.fillScreen(background_color); ballx = 64; bally = 80; if (ball_speed > 1) ball_speed--; digitalWrite(left_score,LOW); } else if (ballx >= tft_width ) { right_score --; tft.drawString(2,42, "Left Won!" ,YELLOW,2); tft.drawString(2,62, "Get Ready!" ,GREEN,2); for (int i = 0; i <250; i++){ delay(10); draw_paddles(); } int cur_r = random(0,26); int cur_g = random(0,30); int cur_b = random(0,18); background_color = cur_r | (cur_g << 5) | (cur_b << 11); tft.fillScreen(background_color); ballx = 64; bally = 80; if (ball_speed > 1) ball_speed--;

  digitalWrite(4+right_score,LOW);


}

}

enjoy getting that code to fudge around with i stole it right form here http://lucidtronix.com/tutorials/7 but the point i had to bring up is that i believe the guy before mentioned that it is a muchslower connectionor process than if it were.....were you saying softwareserial was the option then? because im not an explert or novice or maker by any means. but i have picked up along the lines that hardware serial will always trump software serial compilation any day once you get your head wrapped around the brevity of what ports and pins are actually what are used or have the data displayed on the serial ports. and like software is a necessity im afraid, but its as simple as reasigning pins and when that gets too hard going out and just bbuying a mega, haahah hope i sorta helped. id say go out and snag an esplora whilst their like toing a fire clearance sale on the originallt 50$+ boards. but their reference and prebuilt array of sensors is a bit underwhelming for the newbies in what it alll does, but kinda overwhelmine and difficult to transistion onece having looked at some code as it is, but the language is more forg9ving, but i believe their also officially retiring the leonardo espolora and micro series so good luck this tft display kicks bum man and is the only one that hsnt broke

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.