Adding more pins via i²c (in Blocks)

We’ve had a couple of projects where pins are really tight. I’ve looked at multiplexing and using the LED pins and using an i2c screen but they are all less than perfect.

I recently found that there are a couple of micro controllers that allow you to add a bank of pins over i2c. I’ve bought a PCF8574 but there’s also the MCP23017. It seems like if you’re using Python, reading/writing binary states over i2c is really simple, but my daughter isn’t there yet.

Does anyone know of a block-friendly way to do this sort of thing?

1 Like

To be able to write to the pins as if they are extra pins you would need to write a TypeScript extension.

However, you could try using the i2c interface that is given.


If this is still a bit too involved you would write a set of functions for her that do the hard stuff.

It looks like there is already an extension written. I can’t say if it works or not.

I tried to just import it and it didn’t work. You may have to fiddle with it a bit.

Here is an example. My Maqueen Plus V2 robot has the headlights on the i2c bus. I can use the blocks, but here is how I would use the i2c interface directly to get to the LED headlights.

1 Like