16 Digital Inputs/Outputs On Calliope Mini + Custom Blocks

16 Digital Inputs/Outputs On Calliope Mini + Custom Blocks

Control of the MCP23017 with its 16 digital inputs and outputs via I2C and Custom Blocks or as Makecode package

Hard

30 mins

from 10 years on

Story

Somehow the Calliope Mini has too few inputs and outputs for traffic light projects and the like which I would like to do in higher classes. A remedy is an IO-Port Expander. In our case the MCP23017. It offers 2x8 thus 16 inputs and outputs. Every single port has to be programmed as input as well as output. You can assign up to 8 different hardware addresses to the MCP23017 and then use up to 8x16=128 ports. This should be enough for everything.
Basis for everything were the articles of Robert Fromm:
Arduino and I2C (where you can also find the circuit diagram) and Calliope Mini and I2C
Read and be enthusiastic! Thank you Robert!
And it applies as for many Calliope materials

Robert Fromm and Michael Klein
For my students the whole thing is perhaps a bit too stupid if you have to program via Javascript.

So here's the variant about Custom Blocks:

  1. go to https://makecode.calliope.cc

  2. click on Javascript in the block view

  3. click on the arrow in Explorer

  4. the explorer opens and we click on the + button.

  5. Let's go!

  6. a new file custom.ts appears

  7. delete the example file here and insert my version. By clicking on Blocks we have a new Custom Block Menu with the desired functions:

And the sample program written out:
If key 1&2 is pressed (bit values are added) LED 1 and 2 are switched on. LED 2 for key 2 and LED 3 for key 3.
If the LED is to go out after the key has been released, the last otherwise branch should be set to

must be inserted.

Add package
In the meantime I also managed to create a package:
https://github.com/MKleinSB/pxt-MCP23017

1 / 2

Finished board
And here the whole thing with a professionally manufactured circuit board and a suitable project on Hackster.

This text as well as the image is published under a CC BY-SA 3.0 DE license. It was originally published in German
by Michael Klein and translated into English by the Calliope team.

You can find the finished file below.

The program can be opened directly with the MakeCode editor.

hex