Arduino oscilloscope using UTFT library

In the last week I've been designing an oscilloscope with UTFT library, using a screen of 2.4" 320x240.
When measuring the signal from a function generator it does't display well at the screen. After a frequency of about 10Hz it doesn't chart well, the graph also displays me to the top of the screen.
I leave the last code I used.

osci.ino (1.04 KB)

All those LCD statements are going to slow the Arduino. Have alook at this instructables project.

Whay have you got while(vueltas==5){ which seems to be an endless loop within loop()?

...R

Indeed it an endless loop, because I need to keep charting the signal.
I don't want to make an external circuit, i've heard about a conversion to display directly from the function generator to the screen, but I've problems with the charting, because as I said before it only graph well signal below 10 Hz.
Here is where I took the idea Arduino LCD Osciloscopio DEMO - YouTube

alejandroym:
Indeed it an endless loop, because I need to keep charting the signal.

You have missed my point. loop() is already an endless loop. You don't need to make another one.

I don't want to make an external circuit, i've heard about a conversion to display directly from the function generator to the screen, but I've problems with the charting, because as I said before it only graph well signal below 10 Hz.
Here is where I took the idea https://www.youtube.com/watch?v=eKDn3fgMuoA

I doubt if their code is like your code.

Like I said, writing stuff to the display is very slow. Try reading a bunch of values into an array and when that is finished display the contents of the array.

...R

You're right I'm trying to make the ccode with an array, but i don't know how to display the array info into the screen:( this is the new code that I'm typing.

for (val_read=0 ; val_read<319 ; val_read++)
{

Arr [val_read] = analogRead(A5);
Arr [val_read]= Arr [prev_read];
delay(10);
}

I don't know what to do from here.

Arr [val_read] = analogRead(A5);                
       Arr [val_read]= Arr [prev_read];

Take a new reading, store it, then overwrite it.

Why?

Please use code tags.

Sorry my mistake, i didn't realize I was overwritting the info, it has to be like this I think, to use the prev_read as a coordinate to draw a line.

  for (val_read=0 ; val_read<319 ; val_read++)  
 {  
                      
       Arr [val_read] = analogRead(A5);                
      prev_read = val_read;  
           delay(10);
 }

You only need to worry about line-drawing AFTER you have received all the data. So just read the value into a succession of array elements.

 for (val_read=0 ; val_read<319 ; val_read++)  
 {                   
       Arr [val_read] = analogRead(A5);                
           delay(10);
 }

then follow this with another loop to display the data

 for (int n=0 ; n  < 319 ; n++)  
 {                   
       Serial.print(Arr[n]
 }

Obviously you will want to do something a little more sophisticated to display the data - but this is the starting point.

...R