
/*
  Arduino LCD-2000-9225TFTscreen text example For Mega2560
  
  This example demonstrates how to draw text on the 
 TFTscreen 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 30 April 2014 by INHAOS
 
  http://www.inhaos.com
 
 */
 
#include <LCD_2000_9225.h>
// pin definition for the Mega2560
#define cs   40
#define wr   39
#define rs   38 
#define rst  41
#define le   42

#define D0	 37
#define D1	 36
#define D2	 35
#define D3	 34
#define D4	 33
#define D5	 32
#define D6	 31
#define D7	 30


// create an instance of the library
LCD_2000_9225 TFTscreen(cs,wr,rs,rst,le);

const int analogInPin = A0;  //Analog input pin that the potentiometer is attached to
int Value= 0;
char sensorPrintout[10];
int i;
float j;
int adcValue;
char voltage[10];

void setup() {
  // put your setup code here, to run once:
 TFTscreen.setdatapin(D0,D1,D2,D3,D4,D5,D6,D7);
 TFTscreen.begin();

 // clear the screen with a black background
 TFTscreen.fillScreen(RGB(0,0,0));
 
 TFTscreen.setTextColor(0x000);
 // set the font size
 TFTscreen.setTextSize(3);
 //set the corlor of the pen
 TFTscreen.stroke(100,255,255);
 //write the text
 TFTscreen.text("LCD-2000",18,5);
 TFTscreen.stroke(100,255,255);
 TFTscreen.text("DEMO ",50,30);
 //set the corlor of the pen
 TFTscreen.stroke(255,255,255);
 //fill a rounded rectangle
 TFTscreen.fillRoundRect(25,95,120,50,10,0xffff);
 TFTscreen.setTextSize(2);
 TFTscreen.stroke(180,255,255);
 TFTscreen.text("Voltage",90,200);
}

void loop() {
  
  for(i=9999 ;i>0;i--)
  { 
   // Read the value of the sensor on A0  
    adcValue = analogRead(analogInPin);
    j = (adcValue/1024)*3.3;
    String Value = String(j);
    Value.toCharArray(voltage,4);
   
    String num = String(i);
    num.toCharArray(sensorPrintout,5);
   TFTscreen.stroke(0,0,0);
   TFTscreen.setTextSize(3.5);
   TFTscreen.text(sensorPrintout,50,110);
    
   TFTscreen.stroke(255,255,255);
   TFTscreen.setTextSize(4);
   TFTscreen.text(voltage,0,190);
    delay(200);
   TFTscreen.stroke(255,255,255);
   TFTscreen.setTextSize(3.5);
   TFTscreen.text(sensorPrintout,50,110);
    
   TFTscreen.stroke(0,0,0);
   TFTscreen.setTextSize(4);
   TFTscreen.text(voltage,0,190);
   
  }
}

