# Adding more pins via i²c (in Blocks)

**URL:** https://forum.makecode.com/t/adding-more-pins-via-i-c-in-blocks/31715
**Category:** micro:bit
**Created:** [November 14, 2024, 11:05pm UTC](https://forum.makecode.com/t/adding-more-pins-via-i-c-in-blocks/31715 "2024-11-14T23:05:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Oli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/oli/32/17374_2.png) [@Oli](https://forum.makecode.com/u/Oli)
#### Post date: [November 14, 2024, 11:05pm UTC](https://forum.makecode.com/t/adding-more-pins-via-i-c-in-blocks/31715/1 "2024-11-14T23:05:24Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Don](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/don/32/17989_2.png) [@Don](https://forum.makecode.com/u/Don)
#### Post date: [November 17, 2024, 7:45pm UTC](https://forum.makecode.com/t/adding-more-pins-via-i-c-in-blocks/31715/2 "2024-11-17T19:45:54Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/3/d3de0de476bcf63c8cca8f5fe8efb0a6d088090a.png)  
If this is still a bit too involved you would write a set of functions for her that do the hard stuff.

---

<div class="post-metadata">

### Author: ![Don](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/don/32/17989_2.png) [@Don](https://forum.makecode.com/u/Don)
#### Post date: [November 17, 2024, 7:46pm UTC](https://forum.makecode.com/t/adding-more-pins-via-i-c-in-blocks/31715/3 "2024-11-17T19:46:20Z")

</div>

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

> **[GitHub - rsp-esl/pxt-pcf8574: PCF8574: A Makecode-Microbit extension](https://github.com/rsp-esl/pxt-pcf8574/tree/master)**
>
> master

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

---

<div class="post-metadata">

### Author: ![Don](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/don/32/17989_2.png) [@Don](https://forum.makecode.com/u/Don)
#### Post date: [November 17, 2024, 8:43pm UTC](https://forum.makecode.com/t/adding-more-pins-via-i-c-in-blocks/31715/4 "2024-11-17T20:43:34Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/e/6/e6dd12812dcf92686130a8d59f1b400d1a4cb317.png)
