How often to call functions - BleepLabs/Arduino-Light-And-Sound GitHub Wiki

When adding any code, ask yourself how fast each function should be happening.
Should it be going as fast as possible in the "bottom" of the loop or should it be in a "timing if", and if so at what interval?

digitalRead can be done in the bottom of the loop. It good to read them quickly so they feel responsive.

analogRead doesn't need to be done as fast. Usually having them happen every 1 or 2 milliseconds is as fast as they need to happen. Also think about only doing them at the rate at which their change will be needed. Our screen is only updating 30 times a second so just do the analog reading in the same timing if.

Serial.print() shouldn't be done faster than every 10 milliseconds. Other wise you can overload the serial monitor.

leds.show() should only be done once a frame. We've been doing it at 30 milliseconds which his about 30 frames per second.