Friday, September 26, 2014

Esplora TFT work on Arduino Uno

The Arduino TFT screen is a backlit LCD screen with headers, designed to fit Arduino Esplora or the Arduino Robot. This module is also compatible with any AVR-based Arduino (Uno, Leonardo, etc...) or with the Arduino Due. Read Connecting to other Arduino boards for more details.

This example, TFTGraph, run on Arduino Uno board, reads the value of analog input on A0, and graphs the values on the screen.

To connect Arduino TFT to Arduino Uno board:

Run example of TFTGraph example from Arduino IDE, File > Examples > TFT > Arduino > TFTGraph.


 TFT Graph

 This example for an Arduino screen reads
 the value of an analog sensor on A0, and
 graphs the values on the screen.

 This example code is in the public domain.

 Created 15 April 2013 by Scott Fitzgerald


#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

TFT TFTscreen = TFT(cs, dc, rst);

// position of the line on screen
int xPos = 0;

void setup() {
  // initialize the serial port

  // initialize the display

  // clear the screen with a pretty color
  TFTscreen.background(250, 16, 200);

void loop() {
  // read the sensor and map it to the screen height
  int sensor = analogRead(A0);
  int drawHeight = map(sensor, 0, 1023, 0, TFTscreen.height());

  // print out the height to the serial monitor

  // draw a line in a nice color
  TFTscreen.stroke(250, 180, 10);
  TFTscreen.line(xPos, TFTscreen.height() - drawHeight, xPos, TFTscreen.height());

  // if the graph has reached the screen edge
  // erase the screen and start again
  if (xPos >= 160) {
    xPos = 0;
    TFTscreen.background(250, 16, 200);
  else {
    // increment the horizontal position:


No comments:

Post a Comment