Tell us about yourself!

Complete Your Profile
  • Cheap TFT 2.2 inch Display on Arduino (ILI9340C or ILI9341)

    I am using the 2.2 TFT w/ILI 9340C. I got it to work just fine but I can only do text character. How can I display a variable, like a sensor value? #include "SPI.h"#include "Adafruit_GFX.h"#include "Adafruit_ILI9340.h"#if defined(__SAM3X8E__) #undef __FlashStringHelper::F(string_literal) #define F(string_literal) string_literal#endif// These are the pins used for the UNO// for Due/Mega/Leonardo use the hardware SPI pins (which are different)#define _sclk 13#define _miso 12#define _mosi 11#define _cs 10#define _dc 9#define _rst 8// Using software SPI is really not suggested, its incredibly slow//Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);// Use hardware SPIAdafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);int sen...

    see more »

    I am using the 2.2 TFT w/ILI 9340C. I got it to work just fine but I can only do text character. How can I display a variable, like a sensor value? #include "SPI.h"#include "Adafruit_GFX.h"#include "Adafruit_ILI9340.h"#if defined(__SAM3X8E__) #undef __FlashStringHelper::F(string_literal) #define F(string_literal) string_literal#endif// These are the pins used for the UNO// for Due/Mega/Leonardo use the hardware SPI pins (which are different)#define _sclk 13#define _miso 12#define _mosi 11#define _cs 10#define _dc 9#define _rst 8// Using software SPI is really not suggested, its incredibly slow//Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);// Use hardware SPIAdafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _rst);int sensorPin = A0;int sensorValue ;char sensorPrintout[4]; void setup() {// put your setup code here, to run once: Serial.begin(9600); while (!Serial); Serial.println("Adafruit 2.2\" SPI TFT Test!"); tft.begin(); Serial.print(F("Text ")); Serial.println(testText()); delay(3000);}void loop() { // put your main code here, to run repeatedly: String sensorValue = String(analogRead(sensorPin)); sensorValue.toCharArray(sensorPrintout, 4);}unsigned long testText() { tft.fillScreen(ILI9340_WHITE); unsigned long start = micros(); tft.setCursor(1, 2); tft.setTextColor(ILI9340_BLACK); tft.setTextSize(3); tft.println("LOVE YOU LANA"); tft.setCursor(120, 2); tft.setTextColor(ILI9340_RED); tft.setTextSize(2); tft.println(sensorPrintout); return micros() - start;}

    View Instructable »