0% found this document useful (0 votes)
4 views1 page

Thank 88

This document provides an example code for the Esplora with an Arduino TFT that reads light sensor values and graphs them on the screen. It initializes the TFT display, reads the sensor, and draws a line representing the sensor value. The graph resets when it reaches the edge of the screen, allowing for continuous display of sensor data.

Uploaded by

mrkoh685
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Thank 88

This document provides an example code for the Esplora with an Arduino TFT that reads light sensor values and graphs them on the screen. It initializes the TFT display, reads the sensor, and draws a line representing the sensor value. The graph resets when it reaches the edge of the screen, allowing for continuous display of sensor data.

Uploaded by

mrkoh685
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/*

Esplora TFT Graph

This example for the Esplora with an Arduino TFT reads


the value of the light sensor, and graphs the values on
the screen.

This example code is in the public domain.

Created 15 April 2013 by Scott Fitzgerald

http://www.arduino.cc/en/Tutorial/EsploraTFTGraph

*/

#include <Esplora.h>
#include <TFT.h> // Arduino LCD library
#include <SPI.h>

// position of the line on screen


int xPos = 0;

void setup() {

// initialize the screen


EsploraTFT.begin();

// clear the screen with a nice color


EsploraTFT.background(250, 16, 200);
}

void loop() {

// read the sensor value


int sensor = Esplora.readLightSensor();
// map the sensor value to the height of the screen
int graphHeight = map(sensor, 0, 1023, 0, EsploraTFT.height());

// draw the line in a pretty color


EsploraTFT.stroke(250, 180, 10);
EsploraTFT.line(xPos, EsploraTFT.height() - graphHeight, xPos,
EsploraTFT.height());

// if the graph reaches the edge of the screen


// erase it and start over from the other side
if (xPos >= 160) {
xPos = 0;
EsploraTFT.background(250, 16, 200);
} else {
// increment the horizontal position:
xPos++;
}

delay(16);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy