Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By buzzy
#78228 I am using a 74HC595 to get more pins on my esp8266. With the "normal" pins of the esp8266, I usually use interrupts to be notified of changes to pin status. Is there a way to do this with the extra pins I get of the SPI interface? Thanks!
User avatar
By sfranzyshen
#80082
buzzy wrote:Seems you are wrong. This guy uses it with interrupts.
https://www.youtube.com/watch?v=nXl4fb_LbcI


Simple Answer: Yes!

Winded Answer:
This example uses the 74HC595 shift (SIPO) register ... and more importantly "diodes" ... the code first pulls all the lines high ... when a button is pressed ... any button ... it feeds voltage into a voltage divider and then it's feed into a gpio ... any gpio on the esp8266 (except gpio16) ... using attachInterrupt() (not going into detail here) you would declare the gpio to trigger an ISR (interrupt service routine ... look it up) then the code will one by one turn on each line (diodes prevent back voltage) to see what button(s) is(are) pressed ... the problem (not a problem if speed isn't a problem) here is the time it takes to poll all the buttons one by one ... this method is clever ... and works ... but there is a better way to handle extra inputs 74HC165 ...

https://github.com/sfranzyshen/74HC165-ESP8266

The nice things about using the 74HC165 for input is that you can use them along side using a 74HC595 to handle output ... and synchronously communicated to both chips using hardware SPI simultaneously ... even within the same function call ... way faster than any (bitbang) i2c expansion board ... way cheaper than any i2c expansion board ... and way more scale(able) ... and easier to code too!
Code: Select allbyte 74HC165; // In
byte 74HC595; // Out
SPI.begin ();

{some latch manipulation code here}
74HC165 = SPI.transfer(74HC595); // BOOM!
Last edited by sfranzyshen on Wed Jan 16, 2019 1:38 am, edited 3 times in total.