Week 7 Recipe: Input Testing

Measuring speed one beat at a time

Serves: One electronics chef and a responsive accelerometer

Total Time: Several hours of coding, testing, and pacing around the lab

Course 1: Preparing the Ingredients

For input week, I already had the benefit of a fully milled and soldered PCB with an onboard accelerometer, designed in Week 4 and fabricated in Week 5. Having a complete and tested board allowed me to focus entirely on using the sensor as an input device rather than debugging hardware connections.

Fully soldered PCB with accelerometer
Fully soldered PCB from Week 5, featuring the accelerometer used as the primary input device.

The accelerometer is responsible for detecting motion when the board is moved. Since this project is centered around walking speed, the repetitive motion of steps produces a clear, rhythmic signal that can be interpreted as tempo.

Course 2: Cooking the Code

I wrote code to continuously read acceleration data from the sensor and translate that motion into steps per minute (SPM), which maps directly to musical beats per minute (BPM). Rather than relying on a single axis, I calculated the overall acceleration magnitude so that the system would work even if the board rotated slightly while walking.

Each step creates a noticeable spike in acceleration. By setting a threshold, the code detects when a spike exceeds that value and counts it as a step. To prevent double-counting the same step, a short delay is enforced after each detection.

The code shown below handles reading the accelerometer values, detecting step events, and tracking how frequently those steps occur.

Input code 1
1️⃣ Code for reading accelerometer values and detecting motion
Input code 2
2️⃣ Logic for processing motion data and tracking walking speed

Course 3: From Steps to BPM

Once steps are detected, the system counts how many occur within a fixed time window and scales that value to compute steps per minute. In early testing, I grouped the results into slow, medium, and fast walking speeds to confirm that the accelerometer input was behaving as expected.

This coarse categorization made it easy to verify that changes in walking pace were being registered correctly before moving on to more precise BPM matching in later weeks.

Course 4: Tasting the Results

As shown in the output below, changes in walking speed are clearly reflected in the measured BPM values. This confirms that the accelerometer functions successfully as an input device and that physical motion is being reliably converted into tempo data.

Input proof output
Serial output demonstrating successful registration of walking speed using the accelerometer.

This input system forms the foundation of the final project. In Week 8, this BPM information is paired with audio output, and in the Final Project it becomes the core mechanic of the musical shoe.