Hello, thanks for view my post.
I'm triyng to make a graph in a 3.5 TFT LCD SHIELD from an analog read and what I get is a bis section of the screen being filled with the line, but I need a single line, could be just a pixel of width.
The graph I try to see must be between 19 mm and 19 mm, just in the middle of the Y axis, actually I have solved this but the graph fills half of the screen and I can't get how to make just a line, just like when you open the Serial Plotter. I'm using a TFT that has the ILI9486/ILI9488 chip, and I made this run with the MCUFRIEND_kbv.h library. I attach the code and a picture of how my graph is.
#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
#include <Time.h>
MCUFRIEND_kbv tft;
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int xPos = 0;
int n=0;
int16_t ht = 16, top = 3, line, lines = 15, scroll;
void setup(){
tft.reset();
uint16_t id = tft.readID();
tft.begin(id);
tft.setRotation(1);
tft.fillScreen(BLACK);
tft.setTextColor(WHITE);
}
void loop(){
float sensor = analogRead(A5);
float volt=sensor*5/1024;
//If chnages to map(sensor,0,1023....) it will fill all the pot ohm value
float graphHeight = map(sensor,410,614,0,tft.height());
tft.drawLine(xPos, tft.height() - graphHeight, xPos, tft.height(),WHITE);
if (xPos >= 480) {
xPos = 20;
tft.fillScreen(BLACK);
tft.setCursor(120,10);
tft.print("Seismic Wave Sensor");
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(120,300);
tft.print("INGENIERIA GEOFISICA");
tft.drawLine(20,60,20,260,WHITE);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(30,50);
tft.print("19 mm");
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(30,260);
tft.print("19 mm");
}
else {
xPos++;
}
delay(16);
}
I think my problem could be in the part of graphHeight or the tft.drawLine, but I have been using Arduino for short time, and I know you are experts in this. Please I really need help