UNO TFT reading two analog channels

So im stuck, ive found many examples adapted them but stuck. I need to measure 2 analog DC values, and print them on TFT screen. Those are FWD and REF.

Now what i get with this code is jumble, numbers flying around, but there is no refresh, no earsing of previous value, so yount read anything. I have slow internet cant upload video :frowning:

void loop() {
  // read the sensor and map it to the screen height
  RawValue = analogRead(A0);
float FWD=RawValue*(5.0/1023.0);
if(FWD != prev1){

RawValue1 = analogRead(A5);
float REF=RawValue1*(5.0/1023.0);

if(REF != prev2){

Here is the code. Im using 1.8 inch 128x160px SPI TFT from china. Its based on ST7735, but works perfectly with TFT lib. I have some static text which is written in setup and its perfect. So im sure its not the TFT its my coding.

Its my first time playing with please bare with me im learning here :slight_smile:

If I understood you correctly, here is a solution:

With TFT's you have to do the cleaning by yourself. I mean that if you just print new value on top of the old one, the result is something you already described. You have to overwrite old value pixels somehow, right?

How to do it? Well, you've at least two options:

  1. Draw rectangle on top of the text area you want to refresh, colored with same colo(u)r as background
  2. Overwrite your old value with background color just before printing new one with some other color


Thank you friend, that helped however im having trouble with flicker. Ill try to complete the code cause i have to drive few modules, so that will slow down the code a bit, there is also some math involved.

Its just i never used one of these TFT modules, im getting to love it :slight_smile: to have a color capability to add to project is great :slight_smile:

That damned sorry if i just ask too much. Im also just a year old on arduino :slight_smile: havent got a chance to play with it before....its a fun little toy :slight_smile:

What you mean by flickering? All texts flick or just the part you are updating?

If you try update whole display at once, you get some flickering. It's better to update text by writing it over by background color. It keep flicker but you don't see it :slight_smile:


My aplogies for taking long time to reply. Problems at work and i had to pause my TFT play around :smiley:

I have succeded in removing the flicker. Yes the text updating only was flickering, I just added if statement asking if there is a change on analog pin and voila. It works.

Now on to the math solving problems :slight_smile: thank you for your help all the best