Attached are 2 different codes to operate the ads1115 adc. I am using shields from adafruit. But I am not using the adafruit library. The first code at the top of the page. Works as I expect. However, it uses delay(). To change this, I implemented a state machine using a case switch. The state machine progresses through the cases 1 by 1 adding a delete between the transitions. Now the ADC updates have almost 2 seconds between them and it misses the reads from the pots giving big jumps of resolution. I was assigning the ADC output at the end of the loop in the first code. I tried assigning the ADC values within each case and I changed from millis to micros. But still no joy. Can somebody please shed some light why this code is now so slow compared to the first one which worked well. Is there another way to add a wait type function.
adc state.txt (24.2 KB)