user85460: I am going to either chain 4 shift registers, or connect 4 shift registers to an ESP32 that is connected to a computer with bluetooth.
I understand at 3.3 volts, the 74HC165 can run at a clock speed of up to 18mhz. (5mhz at 2v, 25mhz at 4v).
What is normal for monitoring events on the shift registers? Is it normal to endlessly poll the shift registers? Or is a short delay between each read possible and/or desirable?
I cant imagine a reason for wanting to check for "events" (button presses, etc...) 1 million times per second. We could I guess, I just don't know if we should.
(I am new to the ESP32, so I am not sure how maintaining a bluetooth connection impacts things)

user55698: Yes, it's pretty normal to endlessly poll the buttons. Even the original NES controller did it exactly that way, its protocol works exactly like you'd talk to a shift register. Majenko alredy gave an answer on a good polling frequency, here's the additional hardware you'd need to work with interrupts instead of polling:
You'd need to add a bunch of OR gates (or AND gates if your buttons pull down instead of up) in "parallel" to your shift registers, so that you've got one signal with the semantics "(at least) one of the buttons have been pressed".
This signal then can be connected to the SH/LD input of your shift registers, triggering the shift registers to load (i.e. sample and hold) the inputs. In addition, it needs to be connected to one GPIO of your Arduino/ESP, to which you connect an interrupt handler on the software side. That interrupt handler then polls the shift register once (or sets a flag that causes your main loop to poll it). You may need an additional gate and GPIO to allow the polling routine to keep SH/LD HIGH while polling, depending on your use case and how bouncy your buttons are.
You could even use that signal to wake the ESP from deep sleep, poll the buttons once, do whatever needs to be done as a reaction to that button, then go back to deep sleep.
In conclusion: Endless polling is mostly the way to go, because of the hardware overhead to implement an interrupt solution.

user4143: For this you can employ the nyquist-shannon theory for signal sampling.
In short it states that "to sample a signal frequency of X you need at least 2x X samples per second".
So if you know how long a button will be pressed for (or released for, whichever is faster, i.e., the "highest frequency component of interest") then you know you need to sample with an interval of at most half that time.
So for a button that you may press for 100ms you know you need to sample at most every 50ms, preferably faster.

85460: <p>I am going to either chain 4 shift registers, or connect 4 shift registers to an ESP32 that is connected to a computer with bluetooth.</p>
<p>I understand at 3.3 volts, the 74HC165 can run at a clock speed of up to 18mhz. (5mhz at 2v, 25mhz at 4v).</p>
<p>What is normal for monitoring events on the shift registers? Is it normal to endlessly poll the shift registers? Or is a short delay between each read possible and/or desirable?</p>
<p>I cant imagine a reason for wanting to check for &quot;events&quot; (button presses, etc...) 1 million times per second. We could I guess, I just don't know if we should.</p>
<p>(I am new to the ESP32, so I am not sure how maintaining a bluetooth connection impacts things)</p>
 55698: <p>Yes, it's pretty normal to endlessly poll the buttons. Even the original NES controller did it exactly that way, its protocol works exactly like you'd talk to a shift register. <a href="https://arduino.stackexchange.com/a/89881/55698">Majenko alredy gave an answer on a good polling frequency</a>, here's the additional hardware you'd need to work with interrupts instead of polling:</p>
<p>You'd need to add a bunch of OR gates (or AND gates if your buttons pull down instead of up) in &quot;parallel&quot; to your shift registers, so that you've got one signal with the semantics &quot;(at least) one of the buttons have been pressed&quot;.</p>
<p>This signal then can be connected to the SH/LD input of your shift registers, triggering the shift registers to load (i.e. sample and hold) the inputs. In addition, it needs to be connected to one GPIO of your Arduino/ESP, to which you connect an interrupt handler on the software side. That interrupt handler then polls the shift register once (or sets a flag that causes your main loop to poll it). You may need an additional gate and GPIO to allow the polling routine to keep SH/LD HIGH while polling, depending on your use case and how bouncy your buttons are.</p>
<p>You could even use that signal to wake the ESP from deep sleep, poll the buttons once, do whatever needs to be done as a reaction to that button, then go back to deep sleep.</p>
<p>In conclusion: Endless polling is mostly the way to go, because of the hardware overhead to implement an interrupt solution.</p>
 4143: <p>For this you can employ the <em>nyquist-shannon</em> theory for signal sampling.</p>
<p>In short it states that &quot;to sample a signal frequency of X you need at least 2x X samples per second&quot;.</p>
<p>So if you know how long a button will be pressed for (or released for, whichever is faster, i.e., the &quot;highest frequency component of interest&quot;) then you know you need to sample with an interval of <em>at most half</em> that time.</p>
<p>So for a button that you may press for 100ms you know you need to sample at most every 50ms, preferably faster.</p>
