Now I would like to go further with other test. For instance I would like to show the value of an analog input of the Arduino on the display. So starting from the test sketch, I have started to remove what is not needed and to add the code for the analogue input. After some debug, I was able upload and run my custom made sketch. Is possible to see the value of the analog input on the display just for few moments; every time the task is repeated the value is overwritten and in few seconds the values became unreadable. The only way I have found to make the value readable is by putting "tft.fillScreen(BLACK)" command before calling "tft.print" but the visual result is not good because the display is now blinking..
Thanks in advance for your help!! :)
I'm attaching below the code that I'm using:
Code: Select all
#define sclk 13
#define mosi 11
#define dc 4
#define cs 5
#define rst 6
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
int sensorPin0 = A0;
int sensorPin1 = A1;
int sensorValue0 = 0; // variable to store the value coming from the sensor
int sensorValue1 = 0; // variable to store the value coming from the sensor
Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, rst);
void setup(void) {
tft.begin();
tft.fillScreen(BLACK);
tft.setTextColor(BLUE);
tft.setTextSize(2);
}
void loop() {
sensorValue0 = analogRead(sensorPin0);
sensorValue1 = analogRead(sensorPin1);
//tft.fillScreen(BLACK);
tft.setTextColor(BLUE);
tft.setCursor(0, 0);
tft.print(sensorValue0);
tft.setTextColor(GREEN);
tft.setCursor(0, 15);
tft.print(sensorValue1);
delay(50);
}