This is an odd convention, reading the value in once outside of the for loop, then reading it three times in the for loop, then averaging it. I would prefer to see this as: 1. Initialize the value to 0 2. Set a local variable called `samples` to the number of samples to take 3. For loop for `samples` iterations, accumulating the value 4. Divide the accumulated value by `samples` This avoids magic numbers and having the analog in reading logic duplicated. If we needed to update the analog in logic there's two places that we could forget to update in this function alone. There's another odd convention where the while loop isn't even consuming the sampled value, it's making logic decisions based on an instantaneous reading. ```c void funct() { float myVoltIn, holdvolt, change; while ((myVoltIn = anaInVolts(9)) < ((((float)leakhold) / 10.0) + .5)) { myVoltIn = (anaInVolts(9) - .5) * 10; // going to average these out for (i = 0; i < 3; i++) myVoltIn = myVoltIn + (anaInVolts(9) - .5) * 10; myVoltIn = myVoltIn / 4.0; // Loop continues // myVoltIn is consumed and rendered to the user } ``` _This is a page in the collection of [[Chip Overflow/Willies|snippets that give me the willies]]_