Battery-Powered MIDI Controller with nRF52840, AS5600 Encoders, and OLED Display
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is a MIDI Controller that utilizes an nRF52840 ProMicro microcontroller, multiple AS5600 magnetic encoders, an Adafruit TCA9548A I2C multiplexer, a 128x64 OLED display, and several pushbuttons. The circuit reads the position of the magnetic encoders and displays text on the OLED screen based on the rotation of each encoder. It also handles button presses to send MIDI signals.
Component List
AS5600 Magnetic Encoder
- Description: Magnetic rotary position sensor.
- Pins: DIR, SCL, SDA, GP0, VCC, OUT, GND
nRF52840 ProMicro
- Description: Microcontroller board based on the nRF52840 SoC.
- Pins: B+, RAW, GND, RST, VCC, 31, 29, 2, 115, 113, 111, 10, 600, B-, 6, 8, 17, 20, 22, 24, 100, 11, 104, 106, 107, 102, 101
Pushbutton
- Description: Simple pushbutton switch.
- Pins: Pin 2, Pin 1, Pin 3, Pin 4
Resistor
- Description: 10k Ohm resistor.
- Pins: pin1, pin2
- Properties: Resistance: 10k Ohms
2000mAh Battery
- Description: Power source for the circuit.
- Pins: VCC, GND
128x64 OLED Display (I2C IIC SPI Serial)
- Description: OLED display for visual output.
- Pins: GND, SDA, SCL, VCC
Adafruit TCA9548A
- Description: I2C multiplexer.
- Pins: 2SDA, 2SCL, 3SDA, 3SCL, 4SDA, 4SCL, 5SDA, 5SCL, 6SDA, 6SCL, 7SDA, 7SCL, VCC, GND, INPUTSDA, INPUTSCL, RESET, A0, A1, A2, 0SDA, 0SCL, 1SDA, 1SCL
Wiring Details
AS5600 Magnetic Encoder
SDA connected to Adafruit TCA9548A pin 2SDA
SCL connected to Adafruit TCA9548A pin 2SCL
SDA connected to Adafruit TCA9548A pin 3SDA
SCL connected to Adafruit TCA9548A pin 3SCL
SDA connected to Adafruit TCA9548A pin 4SDA
SCL connected to Adafruit TCA9548A pin 4SCL
SDA connected to Adafruit TCA9548A pin 5SDA
SCL connected to Adafruit TCA9548A pin 5SCL
SDA connected to Adafruit TCA9548A pin 6SDA
SCL connected to Adafruit TCA9548A pin 6SCL
SDA connected to Adafruit TCA9548A pin 7SDA
SCL connected to Adafruit TCA9548A pin 7SCL
SDA connected to Adafruit TCA9548A pin 1SDA
SCL connected to Adafruit TCA9548A pin 1SCL
VCC connected to Resistor pin1, nRF52840 ProMicro pin VCC, AS5600 Magnetic Encoder VCC pins
GND connected to Pushbutton pin 2, Resistor pin2, nRF52840 ProMicro pin GND, AS5600 Magnetic Encoder GND pins
nRF52840 ProMicro
- GND connected to Adafruit TCA9548A pin GND
- Pin 2 connected to Adafruit TCA9548A pin INPUTSDA
- Pin 29 connected to Adafruit TCA9548A pin INPUTSCL
- B+ connected to 2000mAh Battery pin VCC
- 31 connected to 128x64 OLED Display pin VCC
- B- connected to 2000mAh Battery pin GND
- GND connected to 128x64 OLED Display pin GND
- Pin 17 connected to Pushbutton pin 3
- Pin 20 connected to Pushbutton pin 3
- Pin 22 connected to Pushbutton pin 3
- Pin 24 connected to Pushbutton pin 3
- Pin 100 connected to Pushbutton pin 3
- Pin 11 connected to Pushbutton pin 3
- Pin 104 connected to Pushbutton pin 3
Pushbutton
- Pin 2 connected to AS5600 Magnetic Encoder GND, Pushbutton pin 2, Resistor pin2, nRF52840 ProMicro pin GND, Pushbutton pin 2
Resistor
- pin1 connected to AS5600 Magnetic Encoder VCC, nRF52840 ProMicro pin VCC
- pin2 connected to Pushbutton pin 2, nRF52840 ProMicro pin GND
2000mAh Battery
- VCC connected to nRF52840 ProMicro pin B+
- GND connected to nRF52840 ProMicro pin B-
128x64 OLED Display (I2C IIC SPI Serial)
- SDA connected to Adafruit TCA9548A pin 0SDA
- SCL connected to Adafruit TCA9548A pin 0SCL
- VCC connected to nRF52840 ProMicro pin 31
- GND connected to nRF52840 ProMicro pin GND
Adafruit TCA9548A
- GND connected to nRF52840 ProMicro pin GND
- INPUTSDA connected to nRF52840 ProMicro pin 2
- INPUTSCL connected to nRF52840 ProMicro pin 29
- 0SDA connected to 128x64 OLED Display pin SDA
- 0SCL connected to 128x64 OLED Display pin SCL
- 1SDA connected to AS5600 Magnetic Encoder pin SDA
- 1SCL connected to AS5600 Magnetic Encoder pin SCL
- 2SDA connected to AS5600 Magnetic Encoder pin SDA
- 2SCL connected to AS5600 Magnetic Encoder pin SCL
- 3SDA connected to AS5600 Magnetic Encoder pin SDA
- 3SCL connected to AS5600 Magnetic Encoder pin SCL
- 4SDA connected to AS5600 Magnetic Encoder pin SDA
- 4SCL connected to AS5600 Magnetic Encoder pin SCL
- 5SDA connected to AS5600 Magnetic Encoder pin SDA
- 5SCL connected to AS5600 Magnetic Encoder pin SCL
- 6SDA connected to AS5600 Magnetic Encoder pin SDA
- 6SCL connected to AS5600 Magnetic Encoder pin SCL
- 7SDA connected to AS5600 Magnetic Encoder pin SDA
- 7SCL connected to AS5600 Magnetic Encoder pin SCL
Code Documentation
nRF52840 ProMicro Code
/*
* MIDI Controller using nRF52840 ProMicro, AS5600 Encoders, TCA9548A I2C Mux,
* 0.96" OLED Display, and 4 Push Buttons.
*
* This code reads the position of four AS5600 magnetic encoders and displays
* text on the OLED screen based on the rotation of each encoder. It also
* handles button presses to send MIDI signals.
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_TCA9548A.h>
#include <MIDI.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET