This will be throwing me data, for example, every 50ms.
And I have 3 variables (x1, x2 and x3). Where x1 will be the sensor value at 50ms, x2 at 100ms and x3 at 150ms.
My question is: How do I assign these values to the variables? In addition, the sensor will continue tanking values every 50ms, so, when its take the next value. My x1 will be at 100ms, x2 at 150ms and x3 at 200ms, again, for example.
I think that it can be do with a char array, that is the reason for the name of the post. But I'm not sure xD!
Best regards!!
Example for a sr04 taking values every 50ms:
#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;
unsigned long t = millis();
void setup() {
Serial.begin(9600);
delay(1000);
}
void loop() {
dist = sr04.Distance();
vol = ((PI * (10*10)) * dist);
if (millis() - t >= 50)
{
Serial.println(vol);
t = millis();
}
}