I have a vibration sensor and I read the data by using analogRead. I want to sample the value 100 times per second and put them into a set. Then use a serial monitor to display it. The code I used is here
#define VIBRATION_SENSOR A0
int vibdat[100]; // vibration 100 samples in one second
int count = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(VIBRATION_SENSOR, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
for (count=0;count<100;count++){
vibdat[count] = analogRead(VIBRATION_SENSOR);
}
Serial.println(vibdat[count]);
}
The output is a large number 134536520 all the time. My question is how can I sample 100 date in a minute and put them into a set, then using serial print to display it?
Thanks for you help ! I got the right output. And I have another question, can I convert this set of vibration data into a string like String = 123,333,456,123,999,..... I am doing a Iot project, and I would like to send the string to the cloud.