Home Code Arduino tip sampling analog data

Arduino tip sampling analog data

by shedboy71

Sampling sata is particularly useful for analog sensors such as an LDR or a thermistor

You can change the amount of samples to take and the interval which is in millioseconds

int sampleData(int analogPin, int samples = 10, int sampleInterval = 100) 
int sampleData[samples];
int val = 0;
for (int i = 0; i<samples; i++) 
sampleData[i] = analogRead(analogPin);
val = val + sampleData[i];
val = (val / samples);
return map(val, 550, 1023, 100, 0);

You may also like

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More