


/*
  Arduino LCD-2000-9225TFTscreen text example For UNO
  
  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 Uno 
#define cs   11
#define wr   10
#define rs   12 
#define le   13 

#define D0	 9
#define D1	 8
#define D2	 7
#define D3	 6
#define D4	 5
#define D5	 4
#define D6	 3
#define D7	 2

// create an instance of the library
LCD_2000_9225 TFTscreen(cs,wr,rs,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);
   
  }
}

