|
Simone: a game of visual memory and speed
|
This project demonstrates how the project Simone works using a matrix keyboard and an RGB LED to emulate the classic game Simon. It uses a finite state machine (FSM) to control the keyboard, an RGB light (RGB LED) to show the intensity, and a button to interact with the system.
This project is intended to be used with the MatrixMCU toolkit. The toolkit is available at GitHub: MatrixMCU.
Click on the image to see the video showing the Simone demo for Nucleo STM32:
You can access the documentation of the project at: Simone Documentation.
In Version 1, the system works with the user button only. The user button is connected to the pin PC13. The code uses the EXTI13 interrupt to detect the button press.
| Parameter | Value |
|---|---|
| Pin | PC13 |
| Mode | Input |
| Pull up/ down | No push no pull |
| EXTI | EXTI13 |
| ISR | EXTI15_10_IRQHandler |
| Priority | 1 |
| Subpriority | 0 |
| Debounce time | 100-200 ms |
You can start from the HW dependent part of Version 1.
This is the FSM of the button:
In Version 2, the system adds the keyboard matrix to read the presses of the player in the game.
The connections of the keyboard are shown in the table below:
| Parameter | Value |
|---|---|
| Pin row 1 | PA0 |
| Pin row 2 | PA1 |
| Pin row 3 | PA4 |
| Pin row 4 | PB0 |
| Mode rows | Output |
| Pull up/ down rows | No push, no pull |
| Timeout excitation rows | 25 ms |
| Pin/ EXTI/ ISR column 1 | PA8/ EXTI8/ EXTI9_5_IRQHandler |
| Pin/ EXTI/ ISR column 2 | PB10/ EXTI10/ EXTI15_10_IRQHandler |
| Pin/ EXTI/ ISR column 3 | PB4/ EXTI4/ EXTI4_IRQHandler |
| Pin/ EXTI/ ISR column 4 | PB5/ EXTI5/ EXTI9_5_IRQHandler |
| Mode columns | Input |
| Pull up/ down columns | Pull down |
| Priority all columns | 1 |
| Subpriority all columns | 1 |
| Debounce time all columns | 100-200 ms |
The system uses 1 timer to control the duration of the excitation of each row in the keyboard matrix. The characteristics of this timer are shown in the table below. The FSM will give a value every PORT_KEYBOARDS_TIMEOUT_MS milliseconds.
| Parameter | Value |
|---|---|
| Timer | TIM5 |
| Prescaler | (to be calculated for PORT_KEYBOARDS_TIMEOUT_MS) |
| Period | (to be calculated for PORT_KEYBOARDS_TIMEOUT_MS) |
| ISR | TIM5_IRQHandler() |
| Priority | 2 |
| Subpriority | 0 |
You can start from the HW dependent part of Version 2.
This is the FSM of the keyboard:
In Version 3, the system adds the RGB light, which is an RGB LED. The RGB LED is connected to the pins PB6 (red), PB8 (green), and PB9 (blue). The code uses the TIM4 timer to control the frequency of the PWM signal for each color. The RGB LED will show the intensity depending on the difficulty level. The characteristics of the RGB light are shown in the table below.
| Parameter | Value |
|---|---|
| Pin LED red | PB6 |
| Pin LED green | PB8 |
| Pin LED blue | PB9 |
| Mode | Alternative |
| Pull up/ down | No pull |
| Timer | TIM4 |
| Channel LED red | (see the Alternate Function table in the datasheet) |
| Channel LED green | (see the Alternate Function table in the datasheet) |
| Channel LED blue | (see the Alternate Function table in the datasheet) |
| PWM mode | PWM mode 1 |
| Prescaler | (to be calculated for a frequency of 50 Hz) |
| Period | (to be calculated for a frequency of 50 Hz) |
| Duty cycle LED red | (variable, depends on the color to show) |
| Duty cycle LED green | (variable, depends on the color to show) |
| Duty cycle LED blue | (variable, depends on the color to show) |
You have a list full of colors in www.downtownuplighting.com although not all can be shown on an RGB LED.
You can start from the HW dependent part of Version 3.
This is the FSM of the RGB light:
In Version 4 the system completes its FSM to interact with the user button, the keyboard, and the RGB light. The system will work as a game where the player has to repeat a sequence of colors shown by the RGB light by pressing the corresponding keys on the keyboard. The system will increase the length of the sequence with each successful round, and it will provide visual feedback through the RGB light for correct and incorrect inputs.
There are no files documented for the FSM of Version 4, and you have to create them from scratch following the laboratory notebook. You can use the files of the previous versions as a reference.
Check the HW dependent part of Version 4.
YOU MUST DRAW THE FSM OF THE SYSTEM BY YOURSELF AND PUT IT HERE.
In Version 5 the user adds its own functions to the system. Check the manual of the system to know how to add your own functions.
Download this project and place it in the projects folder of the MatrixMCU toolkit.
Be sure that you fulfill the prerequisites of the MatrixMCU toolkit and it is up to date.
Watch this video to better understand how to document your code with Doxygen:
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments to all professors of the SDG2 subject.
In memory of Mario Garrido Gálvez (1981-2025), a great professor and colleague. RIP.