I was writting a code including ADC and i want to count changes in voltage. The program include lots of if() else() so i used a while() loop to count changes to increase speed . But program in while() is working even slower than before.
After changing prescale to 16 for ADC there was improvement but still i can count upto 10000 changes per sec using only void loop()
While while() can only count upto 5000.
if we were to know which ADC, which Arduino, how things are wired and powered and have a glimpse on your code, may be we could provide a meaningful input...
@devilsvenom Your findings make little sense outside of the context that supports them.
Please post your code, perhaps two versions if you think so, that we might see why you are getting the results you state.
The slow thing is probably the conversion. How you structure the code, if/else or while or whatever should have little to do with how fast you can loop the loop.
you call many times analogRead() in the same context. read it once and use the variable for the tests. use a bool instead of an int for x but not sure what you are trying to achieve there.