#include #include #include Servo myservo; // create servo object to control a servo Adafruit_ADS1115 ads1115; // construct an ads1115 at default address 0x48 const float multiplier = 0.1875F; int pos = 0; // variable to store the servo position void setup() { Serial.begin(9600); // Set baud rate for serial monitor myservo.attach(9); // The servo is attached to digital pin 9 ads1115.begin(); // Initialize ads1115 // ads1115.setGain(GAIN_TWOTHIRDS); ads1115.setGain(GAIN_ONE); } void loop() { // ++++++++++++ Create array of angles ++++++++++++++++++++ int N_array = 50; int th_array[N_array]; for(int ii = 0; ii < N_array; ++ii) { th_array[ii] = (int)((float)ii)/((float) N_array)*180.0; } // ++++++++++++ Loop on angles and read values +++++++++++++++++ // First, go to angle 0 myservo.write(th_array[0]); Serial.print('\n'); delay(500); // Then, loop on other angles in the array for(int ii = 0; ii < N_array; ++ii) { // Go to that angle myservo.write(th_array[ii]); delay(100); // Read sensors and average values int16_t adc0; float adc0_ave = 0.0; int NAVE = 20; // Average on this many readings for(int iii = 0; iii