Hi. I am using an OLED 3.5-inch TFT Display Shield with Arduino Mega to graph data from a VL53l0X Distance Sensor. I want to keep the display continuous so I use the scroll function.
I am facing a problem. The graph is smooth and responsible in some first seconds, but after like 10 seconds it showed wrong data even I stopped moving the object.
U can see the picture here:
My code is below:
#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_KBV.h> //Hardware-specific library
LCDWIKI_KBV mylcd(ILI9486, 40, 38, 39, -1, 41); //model,cs,cd,wr,rd,reset
#include "Adafruit_VL53L0X.h"
#include <Wire.h>
#include <SPI.h>
Adafruit_VL53L0X lox = Adafruit_VL53L0X();
#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 i;
void setup()
{
Serial.begin(9600);
Wire.begin();
if (!lox.begin()) {
Serial.println(F("Failed to boot VL53L0X"));
while(1);
}
mylcd.Init_LCD();
mylcd.Set_Draw_color(RED);
mylcd.Fill_Screen(WHITE);
mylcd.Set_Text_Size(1);
mylcd.Set_Text_colour(RED);
mylcd.Set_Text_Back_colour(WHITE);
mylcd.Draw_Fast_VLine(40,40,440);
mylcd.Draw_Fast_VLine(39,40,440);
mylcd.Draw_Fast_HLine(40,39,200);
mylcd.Draw_Fast_HLine(40,40,200);
mylcd.Draw_Fast_VLine(89,35,5);
mylcd.Draw_Fast_VLine(139,35,5);
mylcd.Draw_Fast_VLine(189,35,5);
mylcd.Draw_Fast_VLine(239,35,5);
mylcd.Draw_Fast_HLine(35,42,5);
mylcd.Draw_Fast_HLine(35,151,5);
mylcd.Draw_Fast_HLine(35,260,5);
mylcd.Draw_Fast_HLine(35,370,5);
mylcd.Draw_Fast_HLine(35,479,5);
mylcd.Set_Rotation(1);
mylcd.Print_String("0",30,277);
mylcd.Print_String("50",24,227);
mylcd.Print_String("100",18,177);
mylcd.Print_String("150",18,127);
mylcd.Print_String("200",18,77);
mylcd.Print_String("s(mm)",14,67);
mylcd.Set_Rotation(0);
mylcd.Set_Draw_color(BLUE);
}
void loop()
{
for ( i = 0; i <= 436; i+=4) {
VL53L0X_RangingMeasurementData_t measure;
lox.rangingTest(&measure, false);
mylcd.Vert_Scroll(42, 436, i);
mylcd.Draw_Fast_HLine(42,i+40,measure.RangeMilliMeter);
delay(100);
}
}
I am new to arduino so if anyone could help me with this I am very much appreciated it.