GPIO expander with Attiny85

Hello! So I have a quick little question. I found this cool thing here that is supposed to expand the number of GPIO pins. So I was just wondering if it will work on attiny85 digispark clone board. I don't know why it wouldn't, but I never used this thing before so I am just curious.

Best regards,

The MCP23017 is an I2C port expander. According to the ATTINY85 datasheet, the USI (Universal Serial Interface) supports 2 wire mode (aka I2C). So in theory you can use the MCP23017 with your '85.

If i'm reading the datasheet for the '85 correctly, then there is only one USI on the chip, so you would lose the hardware serial port for things like Serial.print() - assuming you were using it in the first place.

I think it should work ok. But if you need that many i/o, better to use an atmega328? You also get more ram & flash memory with the '328.

Yea I was thinking of that but I need to finish this project very soon and for the 328p I would have to wait alot to arrive couse no local shops here sell it :(. Anyway, thank you both for quick answers :slight_smile:

That seems unlikely. Atmega328 is usually more common than attiny85 and mcp23017. Can you get a Nano or a Pro Mini Arduino?

There are also other (simpler/cheaper) options to expand pins: shift registers or PCF8574.

Ohh yeeaaa shift registers, I have no idea how that works but it looks good. Thats exactly what I was looking for :), its much cheaper and here it arrives super fast to me. Yea I wish there were cheap nano clones or something but none are sold in my country(I think... Maybe on some sketchy websites) I ordered 3 from Banggood and because of covid they still haven't arrived hah... I'll try and learn more about shift registers, thanks :smiley:

Shift register provides only input (PISO = parallel in, serial out) or output (SIPO = serial in, parallel out). For “any number” of registers you need a clock pin and a data pin and possibly a latch pin if needed. That means 2 pins for output if you don’t mind slight glitches when shifting data, 3 if you need all outputs to be valid all the time. Always 3 pins for input; at least 4 pins for both input and output.
There are tricks to reduce the amount of pins needed but I wouldn’t use them if possible.

Ah, I see. I think I will use it only for input, cous I wanna connect the DIP switch with 5 positions with it. So 3 pins it is. Nice, that means I will have 2 pins left on attiny + 8 pins with register. Sweet!