Ya lo conseguí amigo, en efecto fue con un array xD
Dejo el codigo:
#include "SR04.h"
#include "math.h"
#define TRIG_PIN 12
#define ECHO_PIN 11
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
int vol;
int dist;
int values[3];
int index = 0;
String arreglo = "";
unsigned long t = millis();
int x1;
int x2;
int x3;
void setup() {
Serial.begin(9600);
delay(1000);
}
void loop() {
if (millis() - t >= 5000)
{
dist = sr04.Distance();
values[index++] = dist;
Serial.println(dist);
t = millis();
if (index >= 3)
{
index = 1;
x1 = values[0];
x2 = values[1];
x3 = values[2];
Serial.print(x1) + Serial.print("/") + Serial.print(x2) + Serial.print("/") + Serial.println(x3);
values[0] = values [2];
}
}
}
Los Serial.print son para cuestion de "pruebas" para ver si si hacia lo esperado. Y el tiempo lo alargue a 5segundos para poder intercalar entre distancias y corroborar.
Adjunto imagen del funcionamiento:
