Skip to content

z3e8/embedded-spi-led-controller

Repository files navigation

Simon SPI Music + LED Controller

Embedded C project for the MSPM0G3507 that plays "Mary Had a Little Lamb" with synced RGB LED patterns, then switches into button feedback mode.

Note: This was a class project. Development was done in a separate private course repo; this repo is a single push of the finished project for personal backup and portfolio use.

Description

This project was built for my digital systems lab using the Simon PCB. The board starts in a song mode where the buzzer plays a melody and the 4 SPI LEDs change patterns with the notes. If any button is pressed, the system leaves song mode and goes into a button mode where each button plays a tone and lights the nearest LED in a different color.

What I liked about this project is that it combines a few low level ideas at once: timers, PWM, GPIO inputs, debouncing, interrupts, SPI communication, and a small state machine. It is not a huge codebase, but it made me think a lot harder about timing and hardware behavior than a normal class coding assignment.

Demo / Screenshots

Live demo link: https://youtu.be/ThFwflj_F1c [Image]

Tech Stack

  • C
  • TI MSPM0G3507 microcontroller
  • SPI for RGB LEDs
  • Timer A PWM for buzzer output
  • Timer G periodic interrupt for state updates
  • Code Composer Studio

Features

  • Plays "Mary Had a Little Lamb" on startup
  • Shows 3 distinct full-board LED patterns mapped to song notes
  • Keeps LED timing aligned with note timing and silence gaps
  • Switches to button mode on the first debounced button press
  • Lights the correct nearby LED for each button
  • Uses interrupt-driven SPI transmit with FIFO refills

Setup

  1. Open Workspace/Lab6 in Code Composer Studio.
  2. Build the project for the MSPM0G3507 target.
  3. Flash it to the Simon board.
  4. Reset the board and test song mode, then button mode.

Architecture

The project is split into small hardware modules plus one state machine that decides what the board should do every 10 ms.

buttons/timer -> lab6.c main loop -> state_machine
state_machine -> buzzer.c -> PWM output
state_machine -> leds.c -> SPI LED packets

lab6.c handles setup and sleep/wake behavior. state_machine.c holds the two main modes and chooses the current buzzer period and LED packet. buzzer.c, buttons.c, timing.c, and leds.c each handle one hardware job.

Future Improvements

  • Add a cleaner way to return from button mode back to song mode
  • Store songs and LED patterns in a more reusable format
  • Add more songs or difficulty/game behavior like the real Simon game
  • Clean up the LED pattern generator so new patterns are easier to make

Challenges and What I Learned

The hardest part was not the state machine itself, it was getting the hardware details to all agree with each other. The button mapping, LED chain order, SPI message format, and active-low button inputs all had to line up exactly or the board would do something that looked half-right but was actually wrong.

One real issue I ran into was that the buzzer worked correctly while the LEDs did not. That taught me that "part of the system works" does not mean the whole design is correct. I had to separate the problem into layers: first check the intended board mapping, then check the state logic, then finally check the SPI transmit code. The final fix ended up being in the LED transmit path, where the FIFO refill behavior had to respect what the hardware could actually accept.

I also learned a lot about writing embedded code that is simple but still structured. Splitting the project into modules made debugging easier, and keeping one clear state machine in the middle made the behavior much easier to reason about.

Credits

Solo project built by Zane Hensley.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors