[ < RETURN_TO_MAIN_BOARD ]
SYS_MODULE // 01

Bumper Button Game

C++ MSP_MCU HAL

> Exec_Summary

Embedded control is a class that most RPI students in the electrical engineering program take their sophomore year. It has a reputation among engineers who have taken the class as being difficult and time consuming due to the abstract topics and low-quality hardware that students are expected to program within certain margins. Some of the abstract topics include microcontroller timers, register manipulation, low-level C++ programming, and interrupts. When I took the class, Lab 2 was a game intended to teach students about all of the topics mentioned above.

> Instructions

The rules of this game are provided in the code template verbatim as follows:

"Instructions: This game is one of memorization. Prior to the " "beginning of this game, you can press all of the bumper buttons to see their associated color. This will not change for the duration of the game." "Afterwards, to begin the game, press the pushbutton on the circuit atop the car. It will show a sequence of five colors which will be the order until completion of the game" "After this, the same sequence will show, however, only four colors will be shown. It is now your job to input the last color of the sequence using the bumper buttons." "This pattern of losing a color in the sequence will continue until only one color is shown. You will only have three seconds to input your individual response (i.e. three seconds for red, another " "three seconds for green). If completed correctly, the LED in the circuit atop the car will begin to blink green, if you do not finish the sequence within the given time or" "give an incorrect pattern, the LED will begin to blink red. Have fun and enjoy this game!!"

> System_Architecture

The program compartmentalizes behavior using functions. We created SysInit(), GPIOinit(), and Timer_Init() using the Hardware Abstraction Layer functions for MSP microcontrollers. These ensure pin I/O directions are set and clocks are configured properly.

The lightSwitcher function toggles lights in a random order based on system time, while the holdOn function delays the microcontroller in 25ms increments. The userInput() function is the core of the logic, handling the input order and ensuring the correct sequence is pressed to proceed. While a button is pressed, a blocking while loop prevents the code from proceeding until un-pressed.

> Results

The program behaviorally worked the first time we uploaded it to the hardware, teaching us the importance of understanding the underlying behavior and theory before starting a design.