I need to record vibration data (I need to plot vibration signal in future) with Arduino Due and I am new. I used one axis accelerometer sensor (ADXL001) that attach the output of sensor (Xout) to pin A3, and used +3.3 V and ground on Due board. I need to record data with sampling rate 10kHz and bit resolution 12 bit. So, I write code as below
int Pin=A3; //Input Pin
int Volt= 3.3; // 3.3 Power Supply on Arduino Due
float volts;
void setup() {
Serial.begin(9600);
}
void loop() {
analogReadResolution(12); // set bit resolution
int val=analogRead(analogPin);
float volts;=(val/4095.0)*arefVolt;
Serial.print(val);
Serial.print(",");
Serial.print(volts);
delay(1); // *****
}
1.My question is, can i set sampling rate with delay code (like in ***** line) or have another way to set it?
2.When vibrating/shaking the sensor, why the results in serial monitor look like not any changes?
Thanks