answersLogoWhite

0

You can use a FOR loop to loop 50 times, add the reading to a variable and then divide by 50 after the loop completes to determine the average. Make sure that you use a variable type large enough to keep the total. Keep in mind that unless you put a delay in the loop the 50 readings will be taken very fast and will probably vary little. You need to consider what a reasonable time to measure to determine what a good average would be, and then add a delay to give you the right period to take the average over. For example, if you want to take the average over 5 minutes (300 seconds), you would need to add a delay(6000) 6 seconds) to stretch it over the measurement time. Keep in mind that your main program loop won't start until the setup process is complete, so in this example the setup process will take five minutes.

User Avatar

Wiki User

14y ago

What else can I help you with?