float V; // Voltage variable float I; // Current variable float Iav; // Current average variable int n; // Counter variable int R; // Raw ADC reading variable int Rav; // Raw Average ADC reading variable void setup() { Serial.begin(9600); // Initate serial monitor } void loop() { for (n=0;n<10;n++) { // Do 10 times over V = analogRead(A0); // Read the voltage on the A0 pin R = V; // Set R equal to the raw ADC value delay(10); //Serial.println(V); V = (V/1023)*5; // Convert the digital ADC value to volts V = V - 2.500; // Subtract the zero current value (Nominally 2.500V, 2.530V for my circuit only) V = V*1000; // Convert the voltage reading to millivolts //Serial.print("V = ");Serial.print(V);Serial.println(" mv"); // For printing out the millivolts value if required I = (V/400)*1000; // Convert the sensor voltage reading to Amps Serial.print("I = ");Serial.print(I);Serial.println(" ma"); // Print out every current value measurement Iav = Iav + I; // Sum up the ten current measurements Rav = Rav + R; // Sum up the tem digital ADC measurments if (n == 9) { // If at the tenth measurement take the average Iav = Iav/10; // Calculate the average current Rav = Rav/10; // Calculate the average digital ADC reading Serial.print("Iav = "); Serial.println(Iav); // Print out the average current value //Serial.print("Readingav = "); Serial.println(Rav); // For printing out the average digital ADC value if required Iav = 0; // Reset the Iav value for the next run Rav = 0; // Reset the Rav value for the next run delay(2000); } } }