ebusinesspages.com photoshopcreative.co.uk drive.google.com www.pusha.se www.facebook.com www.wherezit.com itsmyurls.com www.authorstream.com www.masteromok.com moz.com

Examples > TFT

Esplora TFT Graph

This example for the Esplora with an Arduino TFT screen reads the amount of brightness that falls on the onboard light sensor, and graphs it on screen. This is similar to the serial communication Graph example.

Hardware Required

  • Arduino Esplora
  • Arduino TFT screen


Attach the TFT screen to the socked on your Esplora, with the label "SD Card" facing up.


To use the screen you must first include the SPI and TFT libraries. Don't forget to include the Esplora library as well.

#include <Esplora.h>
#include <TFT.h>
#include <SPI.h>

Create a variable for holding the position of the x-axis of the graph. You'll increment this each loop(). In setup(), initialize the screen and make the background a nice color.

int xPos = 0;

void setup(){

In loop(), read the value from the light sensor, and map it to a value that fits in the screen's height.

void loop(){
  int sensor = Esplora.readLightSensor();
  int graphHeight = map(sensor,0,1023,0,EsploraTFT.height());

Set the stroke color to something that will stand out against the nice color you chose for the background, and draw a line from the bottom of the screen based on the value of the sensor

  EsploraTFT.line(xPos, EsploraTFT.height() - graphHeight, xPos, EsploraTFT.height());

Before closing up loop(), check to make sure the graph hasn't gone past the edge of the screen. If it has, erase everything, and start back at 0 on the x-axis.

if (xPos >= 160) {
    xPos = 0;
  else {

The complete sketch is below :

SORRY, There is an error at our code repository, please inform to web@arduino.cc