#include #include const int xPin = A0; const int yPin = A1; const int zPin = A2; int samples = 20; const int movingAverageSampleCount = 16; int movingAverageSamples[movingAverageSampleCount]; int iteration = 0; Adafruit_ADS1115 ads; void setup() { analogReference(EXTERNAL); Serial.begin(115200); //ads.setGain(GAIN_SIXTEEN); ads.begin(); } void loop() { int16_t results; //results = ads.readADC_Differential_0_1(); results = ads.readADC_SingleEnded(0); movingAverageSamples[abs(iteration % movingAverageSampleCount)] = results; int32_t movingAverage = 0; for(int averageSample = 0; averageSample < movingAverageSampleCount; averageSample++) { movingAverage += movingAverageSamples[averageSample]; } movingAverage /= movingAverageSampleCount; iteration++; Serial.print("SHZ:"); Serial.print(movingAverage, DEC); int xVal = 0; int yVal = 0; int zVal = 0; for(int sample = 0; sample < samples; sample++) { xVal += analogRead(xPin); yVal += analogRead(yPin); zVal += analogRead(zPin); } Serial.print("|ENN:"); Serial.print(xVal); Serial.print("|ENE:"); Serial.print(yVal); Serial.print("|ENZ:"); Serial.print(zVal); Serial.println(); Serial.flush(); }