Designing My Custom Spotify Macroboard

A Step-by-Step Guide to Building a Personalized Macro Keyboard for Spotify

Ben Zhou - Posted: [DATE] - Last Updated: [DATE]

A full demo of my project and its features.


Introduction

For my Computer Engineering Final Performance Task (FPT), I was challenged to apply all the knowledge I had acquired throughout the course to create a project of my own choosing. I chose to design and build a macro keyboard capable of controlling my Spotify music, along with a range of other quality-of-life features.

My inspiration for this project came from the fact that I listen to a lot of music, and with that I often adjust the song playing, as well as other features such as volume or looping. However, since I used a 60% keyboard, that meant that I would have to click 3-4 keys to achieve some simple functionality such as skipping a song.

Therefore, I aimed to build a macroboard that would enable effortless control over my Spotify music while incorporating features like dynamic lighting and a built-in screen to display the current song. The finished product has satisfyingly smooth fading lights, clicky blue switches, a sleek case, and a vibrant display.


Research

Before creating this macroboard, I had to do some basic research. I started by considering the essential functions I wanted my keyboard to have. Firstly, I wanted custom RGB lighting that could match the color of the currently playing music. Additionally, I wanted a screen, even if small, to display the current song and related information. Finally, I aimed to have maximum control over the music player, including the ability to shuffle and loop without needing to manually open Spotify.

For lighting I decided to go for some simple RGB addressable LED strips, this allowed me to control exactly what LEDs I wanted to turn on and off, as well as the colour of the LEDs. This particular LED strip is called the WS2812B and is a popular choice since it is easy to control and has a wide range of colours. This would also allow me to implement some cool lighting effects such as a rainbow wave or a breathing effect.

Testing the LED

After soldering all of the components I gave my project a quick test to see if everything was turning on and working properly.

I next looked at some possible screens, I had used Liquid Crystal Displays before, however, this required a mass amount of pins (up to 14 pins), which would not be sufficient, especially if I wanted to connect multiple other buttons and components to my microcontroller. As such, I then researched other displays and found a smaller display that had the same functionality while only using 2 data pins. In addition, it had simple functions that would allow me to adjust each pixel as I wanted it. I ended up choosing the SSD1306 0.96-inch OLED display. With a resolution of 128x64, it would allow me to have 8 lines of data across a manageable width. This part of the project also introduced me to the I2C communication protocol. In addition to the screen, I also looked for some simple mechanical switches that would allow me to have a somewhat satisfying sound. I settled on some simple blue switches I found on Amazon.

I finally looked at the problem of determining what colour to show based on the album image of the music playing. Unfortunately, simply using the Arduino would never work, mainly due to the fact it is quite limited in both memory and flash storage. To put this into perspective, the average album art, even at scaled-down resolutions, is around 160x160 pixels, even when blurry. Each pixel can be represented by red, blue, and green in every colour. Since the max value for any value is 255 or 3(2^8) bits per pixel. That means roughly, every pixel takes up about 24 bits or 3 bytes. Multiplying that by the 25,600 pixels the average album art has, we get a total of 76,800 bytes or roughly 75 kilobytes.

The Arduino only has 32 kilobytes of flash memory, meaning there's absolutely no way we could even store the images temporarily. As if this wasn't already a big enough problem, I also had to consider how I was going to get the information in the first place, the regular Arduino R3 doesn't have any WiFi or Bluetooth capabilities, meaning that I wouldn't even be able to connect to my phone or laptop wirelessly.

The ESP32 Dev Module 1

The ESP32 Dev Module 1 I used for my project.

Taking into account all of this I looked at one final solution, what if instead I simply used another microcontroller? This brought me to the ESP32 Dev Module 1, this microcontroller has 2.4 GHz WiFi capabilities, full Bluetooth support, as well as 320 kilobytes of storage (520KB - 320 DRAM/200 IRAM). It was much smaller than the regular Arduino, meaning I could save on space and make my keyboard much more compact. However, there was still a lingering issue. I still wouldn't be able to process the images, and I would likely hit memory issues later on.

Therefore I decided to create an API to offload most of the heavy computing. I decided on a simple REST API which allows me to make a GET request to my server, and then receive information or do things based on my request. This allowed me to not only offload processing the album images but also control a lot of things behind the scenes. For example, I originally tried using a public library online that another person had written. Unfortunately, their code wasn't the best as it took on average 3-5 seconds just to make a single API request, by rewriting their code and making use of my API, I was able to bring that down by almost 15 times, with the average request taking around 0.2 seconds on average.


Circuit/PCB Design


User Instructions


Code Review

1
const String PASSWORD = "REDACTED";
2
const char SSID[] = "REDACTED";
3
const char SSID_PASS[] = "REDACTED";

Required Parts

More text


Contacts

Thanks for reading through my website! If you want to contact me please reach out on LinkedIn.

Copyright © 2023-2024 Ben Zhou All rights reserved.

Socials

Check out my socials below!