It kind of worked! This really made me happy. (Just to be clear, I plug this into the 3.3v power source from the arduino?)
The screen now flickers with the animation I have set up. However, the screen only shows when it refreshes. For example in the void setup() portion of my code, the screen will flicker on with the correct text, ie "Hello jaflue !" however it will immediately go dark afterwards even if I set the delay to delay(100000). I even then commented out the tft.clear() command just in case that function was causing the screen to go dim.
#include "SPI.h"
#include "TFT_22_ILI9225.h"
#define TFT_RST 4
#define TFT_RS 3
#define TFT_CS 2 // SS
#define TFT_SDI 11 // MOSI
#define TFT_CLK 13 /// SCK
#define TFT_LED 5 /// 0 if wired to +3V directly
// size of screen is 176x 220
/// Use hardware SPI (faster - on Uno: 13-SCK, 12-MISO, 11-MOSI)
TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_LED);
/// Use software SPI (slower)
//TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_SDI, TFT_CLK, TFT_LED);// USE THIS IF DISPLAY IS HOOKED DIRECTLY INTO ARDUINO
int CircleRadius = 16;
const int n =1;
float x = 0;
float x1=0;
float y1 = 0;
int b = 0;
int x5;
int x4;
int x3;
int x2;
int y5;
int y4;
int y3;
int y2;
int a1 = 106; int a2 = 70; int a3; int a4; int a5; int b1 = 120; int b2 = 100; int bc3; int bd4; int be5;
// Setup
void setup()
{
int CircleRadius = 16;
Serial.begin(9600);
Serial.println("Hello jaflue");
tft.begin();
tft.setFont(Terminal6x8);
tft.drawText(10, 10, "Hello jaflue !", COLOR_BLUE);
delay(100000);
//tft.clear();
}
void loop()
{
if(b <5) {
tft.drawRectangle(a1, b1, a2, b2, COLOR_BLUE);
x1 = x1 + n;
y1 = 2*(x1) + 1;
Serial.begin(9600);
Serial.println("Hello jaflue");
//tft.clear();
//tft.setFont(Terminal2x1);
//tft.drawText(10, 10, "Hello jaflue !")
//tft.setBackgroundColor(COLOR_GREEN);
//delay(1000);
//Serial.println("What radius do you want for the circle?"); //Prompt User for Input
//while(Serial.available()==0) { }// Wait for User to Input Data
//CircleRadius=Serial.parseInt(); //Read the data the user has input
tft.drawPixel(x1, y1, COLOR_BLUE);
tft.drawCircle(110, 88, CircleRadius, COLOR_GREEN); //uint16_t 110, uint16_t 88, uint16_t 16, uint16_t blue
x5 = x1;
b = b +1;
delay(1000);
}
else if(b>=5){
tft.drawRectangle(a1, b1, a2, b2, COLOR_BLACK);
a1 = a1 +1;
b1 = b1+1;
a2 = a2-1;
b2 = b2-1;
tft.drawRectangle(a1, b1, a2, b2, COLOR_BLUE);
tft.drawPixel(x1, y1, COLOR_BLACK);
x5 = x5 +1;
y5 = 2*(x5)+1;
x4 = x5;
x3 = x4-1;
x2 = x3-1;
x1 = x2-1;
y4 = 2*(x4) +1;
y3 = 2*(x3) +1;
y2 = 2*(x2) +1;
y1 = 2*(x1) +1;
tft.drawPixel(x5, y5, COLOR_BLUE);
tft.drawPixel(x4, y4, COLOR_BLUE);
tft.drawPixel(x3, y3, COLOR_BLUE);
tft.drawPixel(x2, y2, COLOR_BLUE);
tft.drawPixel(x1, y1, COLOR_BLUE);
delay(50);
}
}
With everything hooked up correctly. I am not sure what the problem is.
Thank you so much David, you have been a great teacher so far.
Best,
Ian
Edit: I just got it working completely! I though you meant in your previous reply when you said
I believe that you have NC where I have LED. Just ignore LED.
that you meant I didn't/shouldn't have to hook the LED pin from the tft screen. I eventually did connect the LED pin from the screen to digital pin 0 on the UNO, as my screen is plugged directly into the +3V power source from the UNO. Now the display is working as my code specifies! (which actually isn't that functional but I just wanted to test it out).
So for reasons of posterity and in case other people are struggling with the same thing I am struggling with I am attaching pictures of the correctly wired Arduino UNO to the tft ili9225 non-touch screen along with my code that should display "hello jaflue !" and a circle, a growing rectangle and line that moves diagonally across the screen.
#include "SPI.h"
#include "TFT_22_ILI9225.h"
#define TFT_RST 4
#define TFT_RS 3
#define TFT_CS 2 // SS
#define TFT_SDI 11 // MOSI
#define TFT_CLK 13 /// SCK
#define TFT_LED 0 /// 0 if wired to +3V directly
// size of screen is 176x 220
/// Use hardware SPI (faster - on Uno: 13-SCK, 12-MISO, 11-MOSI)
TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_LED);
/// Use software SPI (slower)
//TFT_22_ILI9225 tft = TFT_22_ILI9225(TFT_RST, TFT_RS, TFT_CS, TFT_SDI, TFT_CLK, TFT_LED);// USE THIS IF DISPLAY IS HOOKED DIRECTLY INTO ARDUINO
int CircleRadius = 16;
const int n =1;
float x = 0;
float x1=0;
float y1 = 0;
int b = 0;
int x5;
int x4;
int x3;
int x2;
int y5;
int y4;
int y3;
int y2;
int a1 = 106; int a2 = 70; int a3; int a4; int a5; int b1 = 120; int b2 = 100; int bc3; int bd4; int be5;
// Setup
void setup()
{
int CircleRadius = 16;
Serial.begin(9600);
Serial.println("Hello jaflue");
tft.begin();
tft.setFont(Terminal6x8);
tft.drawText(10, 10, "Hello jaflue !", COLOR_BLUE);
delay(1000);
//tft.clear();
}
void loop()
{
if(b <5) {
tft.drawRectangle(a1, b1, a2, b2, COLOR_BLUE);
x1 = x1 + n;
y1 = 2*(x1) + 1;
Serial.begin(9600);
Serial.println("Hello jaflue");
//tft.clear();
//tft.setFont(Terminal2x1);
//tft.drawText(10, 10, "Hello jaflue !")
//tft.setBackgroundColor(COLOR_GREEN);
//delay(1000);
//Serial.println("What radius do you want for the circle?"); //Prompt User for Input
//while(Serial.available()==0) { }// Wait for User to Input Data
//CircleRadius=Serial.parseInt(); //Read the data the user has input
tft.drawPixel(x1, y1, COLOR_BLUE);
tft.drawCircle(110, 88, CircleRadius, COLOR_GREEN); //uint16_t 110, uint16_t 88, uint16_t 16, uint16_t blue
x5 = x1;
b = b +1;
delay(1000);
}
else if(b>=5){
tft.drawRectangle(a1, b1, a2, b2, COLOR_BLACK);
a1 = a1 +1;
b1 = b1+1;
a2 = a2-1;
b2 = b2-1;
tft.drawRectangle(a1, b1, a2, b2, COLOR_BLUE);
tft.drawPixel(x1, y1, COLOR_BLACK);
x5 = x5 +1;
y5 = 2*(x5)+1;
x4 = x5;
x3 = x4-1;
x2 = x3-1;
x1 = x2-1;
y4 = 2*(x4) +1;
y3 = 2*(x3) +1;
y2 = 2*(x2) +1;
y1 = 2*(x1) +1;
tft.drawPixel(x5, y5, COLOR_BLUE);
tft.drawPixel(x4, y4, COLOR_BLUE);
tft.drawPixel(x3, y3, COLOR_BLUE);
tft.drawPixel(x2, y2, COLOR_BLUE);
tft.drawPixel(x1, y1, COLOR_BLUE);
delay(50);
}
}