Circuit Diagram

How It Works

The ItsyBitsy nRF52840 is running CircuitPython code that allows for MIDI to be received over BLE. Additionally, it's communicating over I2C between two MCP23017's.

The MCP23017 is a multiplexer that expands the number of digital inputs and outputs that a microcontroller can communicate with. In this case, they're allowing for 30 additional outputs for the solenoid motors.

Before the solenoids can be triggered through, the MCP23017's output their signal to a ULN2803. The ULN2803 is a darlington motor driver, which is great for driving solenoids and they can take in 3.3V or 5V logic.

The CircuitPython code on the IstyBitsy nRF52840 sends on and off signals over I2C to the MCP23017's depending on the MIDI note that it receives over BLE. The MCP23017 then sends an on signal, followed quickly by an off signal, to a ULN2308 driver. Finally, the ULN2308 triggers the solenoid to hit a note on the xylophone.

Although there's quite a bit of wiring between the IC's and solenoids, the ItsyBitsy is only using 5 pins, and that's counting power and ground. The use of I2C keeps things nice and compact.



  • 3V from the ItsyBitsy to VDD and RESET on both MCP23017's
  • 3V from the ItsyBitsy to A0 on the second MCP23017
  • USB from the ItsyBitsy to the switch
  • COMMON on all four ULN2308's to USB from the switch


  • GND from the ItsyBitsy to VSS, A2 and A1 on both MCP23017's
  • GND from the ItsyBitsy to A0 in the first MCP23017
  • GND from the ItsyBitsy to GND on all four ULN2308's


  • 2.2K pull-up resistor on both SCL and SDA on the first MCP23017
  • SCL from the ItsyBitsy to SCL on both MCP23017's
  • SDA from the ItsyBitsy to SDA on both MCP23017's


  • The solenoid's wire 1 to the output pins (O1-O8) on all four ULN2803's
  • The solenoid's wire 2 to USB from the switch
A0, A1 and A2 on the MCP23017 determine the I2C address, which is why the wiring differs between the two.

Data Signal Flow

The chart below explains the pinouts for the multiplexers to the drivers and what MIDI note they correspond with.

Note (Name and MIDI #)


MUX (#, Pin Name, Pin #)

Driver (#, Pin Name, Pin Number)

G2 (55)

MUX1, GPA0, Pin 21

Driver 1, I1, Pin 1

G#2 (56)

MUX1, GPA1, Pin 22

Driver 1, I2, Pin 2

A2 (57)

MUX1, GPA2, Pin 23

Driver 1, I3, Pin 3

A#2 (58)

MUX1, GPA3, Pin 24

Driver 1, I4, Pin 4

B2 (59)

MUX1, GPA4, Pin 25

Driver 1, I5, Pin 5

C3 (60)

MUX1, GPA5, Pin 26

Driver 1, I6, Pin 6

C#3 (61)

MUX1, GPA6, Pin 27

Driver 1, I7, Pin 7

D3 (62)

MUX1, GPA7, Pin 28

Driver 1, I8, Pin 8

D#3 (63)

MUX1, GPB0, Pin 1

Driver 2, I1, Pin 1

E3 (64)

MUX1, GPB1, Pin 2

Driver 2, I2, Pin 2

F3 (65)

MUX1, GPB2, Pin 3

Driver 2, I3, Pin 3

F#3 (66)

MUX1, GPB3, Pin 4

Driver 2, I4, Pin 4

G3 (67)

MUX1, GPB4, Pin 5

Driver 2, I5, Pin 5

G#3 (68)

MUX1, GPB5, Pin 6

Driver 2, I6, Pin 6

A3 (69)

MUX1, GPB6, Pin 7

Driver 2, I7, Pin 7

A#3 (70)

MUX1, GPB7, Pin 8

Driver 2, I8, Pin 8

B3 (71)

MUX2, GPA0, Pin 21

Driver 3, I1, Pin 1

C4 (72)

MUX2, GPA1, Pin 22

Driver 3, I2, Pin 2

C#4 (73)

MUX2, GPA2, Pin 23

Driver 3, I3, Pin 3

D4 (74)

MUX2, GPA3, Pin 24

Driver 3, I4, Pin 4

D#4 (75)

MUX2, GPA4, Pin 25

Driver 3, I5, Pin 5

E4 (76)

MUX2, GPA5, Pin 26

Driver 3, I6, Pin 6

F4 (77)

MUX2, GPA6, Pin 27

Driver 3, I7, Pin 7

F#4 (78)

MUX2, GPA7, Pin 28

Driver 3, I8, Pin 8

G4 (79)

MUX2, GPB0, Pin 1

Driver 4, I1, Pin 1

G#4 (80)

MUX2, GPB1, Pin 2

Driver 4, I2, Pin 2

A4 (81)

MUX2, GPB2, Pin 3

Driver 4, I3, Pin 3

A#4 (82)

MUX2, GPB3, Pin 4

Driver 4, I4, Pin 4

B4 (83)

MUX2, GPB4, Pin 5

Driver 4, I5, Pin 5

C5 (84)

MUX2, GPB5, Pin 6

Driver 4, I6, Pin 6

This guide was first published on May 27, 2020. It was last updated on Jun 19, 2024.

This page (Electronics) was last updated on Mar 08, 2024.

Text editor powered by tinymce.