The LEGO Grand Piano 21323 is a great model, full of clever details and impressive engineering.

Gianni had already done a excellent job before, I just continued to improve and reduce the size of the whole module, with some minor adjustments.

Optical Reflective Object Sensor

You can use QRE1113/QRE1114 with analog or digital methods and Arduino codes here.

Normally we use the following connections, but the number of ESP’s GPIO is limited, if we have 25 keys need to drive, we need 25 GPIOs to read the analog then.

Analog Connection
Analog Connection

Gianni used the matrix method to make the number of GPIOs needed lesser, only need 15 GPIOs. And only one sensor is being powered at the same time, which will save more battery power.

  • 15 for sensors
  • 1 for DAC (Digital To Analog Converter)
  • 1 for amplifier enable (because some noise here when we set I2S)

Why choose ESP32-PICO-D4

We need at least 17 GPIO, but ESP8266 only 8 are available. Although we don’t need to use the BLE for now (of course you can also make it as a Bluetooth speaker!).

We could also use the very popular MCU RP2040 but it has more peripheral than the ESP32-PICO-D4 and I’m not familiar enough with it.

Other combination options

You can also use sensor (QRE1113) + analogue switch (TS3V330) + matrix scanning IC (SX1509, has a powerful keypad engine and use I2C communication), however, this requires long periods of power supply to all sensors.

Reference