IMU Air-Drumming Kit

an IMU-based air-drumming kit that turns physical gestures into real-time percussion audio. there are no pads or triggers: you hold a pair of drumsticks with sensors on them, swing at empty air, and the right drum sample plays.
the system is built around an STM32 microcontroller talking to two BNO055 IMUs over I2C. each IMU streams orientation (yaw and pitch) and linear acceleration off a drumstick. from that data the STM32 builds a 3D coordinate system and, using a zero-point center reference, splits the space in front of you into three distinct drum zones. a sharp enough spike in acceleration counts as a strike, and whichever zone the stick is pointing at decides which sample fires.
on a strike, the matching sample is played back by running a DMA transfer straight from flash memory to the STM32's DAC, then out through a PAM8302 amplifier to a speaker. the samples were downsampled to 8 kHz 8-bit to fit inside the chip's 512 KB of flash, which puts the audio throughput at 8 kbps.
i wrote the IMU driver from scratch: pinging the sensor to check the connection, initialization, calibration, and reading the orientation and acceleration data. i also handled the hardware integration, the peripheral interfacing, and the audio playback path, configuring the DAC and DMA for low-latency output and tuning the NVIC priorities and DMA config so audio playback and I2C polling could run at the same time. my partner handled the IMU data ingestion and the angle-to-zone mapping, and we both spent a lot of time chasing the IMUs dropping their I2C connection.
the throughput analysis was the interesting part. the BNO055's sensor fusion caps out at 100 Hz, the I2C bus was left in standard mode at 100 kHz (roughly 1.5 ms per sensor, with the blocking HAL read adding more on top), but the real bottleneck was a UART debug string that stalled the CPU for around 7 ms every loop and dragged the rate down to about 140 Hz. dropping those debug transmissions for the final build was the single biggest speedup, since you don't need a printout of which drum was hit once the audio is actually playing.
the main thing i'd change next time is adding a second sensor, like an ultrasonic transducer or a small camera, to back up the IMU. leaning on a zero-point meant that any sensor drift or change in how you held the sticks needed frequent recalibration. an absolute reference would let the drum zones stay put on their own, without the constant software recalibration.
