Go Down

Topic: Arduino Mega 2560 And ITDB02 Shield (Read 929 times) previous topic - next topic

prakash_prasad

I have purchased Arduino Mega 2560 and 2.8 ITDB02 TFT Shield.

The way I have plugged in the Shield in such a way that SD card place holder of it is at the side of USB connector and leaving the first 2 pins from both side at USB connector of Arduino Mega 2560 board.

Now I am trying the below sample code as in Arduino IDE:

Code: [Select]

/*
  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://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);
}


The code is not working for me - no display is coming.

I am not sure what are the CS, DC and RST pins for Arduino Mega 2560 Board? Where will we get these details - I see that shield has taken the below PINS:


Code: [Select]

Right Side                                Left Side
Reset                                           13
............                                     .....
A5                                              0


Please let me know if I have connected my Shield correctly to Mega 2560 Board and what changes to make in code to make it work?

Go Up