Sunday, May 27, 2018

Teensy 3.6 + 2.8" TFT LCD Display SPI Serial 240*320 ILI9341 connection and code

Just doing some experiments with a Teensy 3.6 microcontroller board, a graphical display and some other bits and pieces.
Since it was not easy to find a single source of information with a code example and pin connections, here's a compilation of it:

Schematic:


For testing porpoises the supply is not needed as long as USB power cable is connected to the board.

Bellow the code to run:

/////////////////////////////////
/*
  Just place some text on the ILI9341 display using a Teensy 3.6
  CT2GQV 2018
*/

#include
#include
#include "font_Arial.h"
#include

#define BACKLIGHT_PIN   3
#define TFT_DC          20
#define TFT_CS          21
#define TFT_RST         255  // 255 = unused. connect to 3.3V
#define TFT_MOSI        7
#define TFT_SCLK        14
#define TFT_MISO        12

ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);


// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6  has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0 and 3.6 by the way
int led = 13;

void setup() {               
  // for the built in LED.
  pinMode(led, OUTPUT);    
  // for the backlight
  pinMode(BACKLIGHT_PIN, OUTPUT );
  analogWrite(BACKLIGHT_PIN, 128); // 0 to 255

  tft.begin();
  tft.setRotation( 3 );
  tft.fillScreen(ILI9341_BLACK);
  tft.setCursor(10, 1);
  tft.setTextSize(2);
  tft.setTextColor(ILI9341_ORANGE);
  tft.setFont(Arial_14);
  tft.print("This side UP");
   tft.setCursor(50, 20);
  tft.setTextSize(2);
  tft.setFont(Arial_10);
  tft.print("Arial 10 font");
 
}

// the loop routine runs over and over again forever:
void loop() {
  // it just blinks the led
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

/////////////////////////////////

Code result:



The display back side (top of the display as on previous picture is the sd card side)



The testing board with backside connections:


 Teensy 3.6 pin assignment diagram.



 Have a nice week!

No comments: