This shows you the differences between two versions of the page.
|
pm:prj2026:theodor_ioan.buliga:alexandru.ocanoaia [2026/05/11 10:17] alexandru.ocanoaia [Hardware Design] |
pm:prj2026:theodor_ioan.buliga:alexandru.ocanoaia [2026/05/27 08:12] (current) alexandru.ocanoaia [Software Design] |
||
|---|---|---|---|
| Line 51: | Line 51: | ||
| While the game is being played, the theme song from Formula 1 will play in the background. | While the game is being played, the theme song from Formula 1 will play in the background. | ||
| + | |||
| ===== Hardware Design ===== | ===== Hardware Design ===== | ||
| Line 110: | Line 111: | ||
| * Role: To turn off the coresponding led. Each led will have a coresponding button. | * Role: To turn off the coresponding led. Each led will have a coresponding button. | ||
| * Each player will have 3 buttons. Normally, a button should use one pin, but this will consume a lot of pins of the board. My solution is to connect 3 buttons on one pin and read the values using adc for determined which button is being pressed. | * Each player will have 3 buttons. Normally, a button should use one pin, but this will consume a lot of pins of the board. My solution is to connect 3 buttons on one pin and read the values using adc for determined which button is being pressed. | ||
| - | * For this part I need to create a voltage divider. Each button will have his own resistance. | + | * For this part I need to create a voltage divider. Each button will have his own resistor. |
| + | |||
| + | This is the electrical scheme for how the buttons and the resistors is being connected. | ||
| + | |||
| + | {{:pm:prj2026:theodor_ioan.buliga:buttons.png?300|}} | ||
| + | |||
| + | I will need a pull-down resistor for the input to read 0 when no button is being pressed. | ||
| + | |||
| + | For pins I will use 2 analog pins (PC0 for player 1 and PC1 for player 2). | ||
| + | |||
| + | 6. Buzzer | ||
| + | |||
| + | * Role: To sing the F1 theme song. | ||
| + | * It will be controlled using PWM. | ||
| + | * It will be connected to the PD3 pin, because the OC2B is on that pin on the atmega328p microcontroller. | ||
| + | |||
| + | {{:pm:prj2026:theodor_ioan.buliga:electric_scheme.png?300|}} | ||
| + | |||
| + | This is the electric scheme of my project, that represent the connections that I detailed in the structure of the components. | ||
| ===== Software Design ===== | ===== Software Design ===== | ||
| + | Link repository: [[https://github.com/AlexOcanoaia/F1_Reaction_Game| Repository]] | ||
| + | |||
| + | The element that is new to this game is the multiplayer mode. Initially the game was a training method for the formula 1 drivers and of course was singleplayer. Because it will be a multiplayer game, will be fun to play with friends and train your reflexes. | ||
| + | |||
| + | <note tip> | ||
| + | For this project, I am gonna use things that I learned from this laboraties: | ||
| + | * **Laboratory 0: GPIO**: for leds | ||
| + | * **Laboratory 1: UART**: for comunicating with the players (asking their names and send the statistics for each player at the end of the game) | ||
| + | * **Laboratory 2: Interupts, Timers**: for implementing debounce and external interupts for buttons. In addition, implementing timers for counting the seconds. | ||
| + | * **Laboratory 3: PWM**: for the buzzer to sing the formula 1 theme song | ||
| + | * **Laboratory 4: ADC**: for the buttons for each player (along with an interupt) and for the potentiometer | ||
| + | * **Laboratory 6: I2C**: for showing information about the score, time on the lcd | ||
| + | </note> | ||
| + | |||
| + | <note> | ||
| + | The structure of my project is: | ||
| + | <code> | ||
| + | Project | ||
| + | | - i2c.c | ||
| + | | - i2c.h | ||
| + | | - adc.c | ||
| + | | - adc.h | ||
| + | | - timers.c | ||
| + | | - timers.h | ||
| + | | - usart.c | ||
| + | | - usart.h | ||
| + | | - utils.c | ||
| + | | - utils.h | ||
| + | | - main.c | ||
| + | </code> | ||
| + | |||
| + | I choose this structure for organizing (each protocol and feature will have a file). This is easier for me to read the code and debug. | ||
| + | </note> | ||
| + | <note tip> | ||
| + | For this project I am gonna use: | ||
| + | * **A state machine**: I am gonna have 3 states (start of the game, middle of the game, end of the game). I will use this concept for dividing my code into 3 parts (I will have interupts that need to be working just in one state of the game). | ||
| + | * No external library | ||
| + | </note> | ||
| + | <note> | ||
| + | Algorithms and data structures used: | ||
| + | * **States of the game**: this is an enum | ||
| + | * **UART Protocol**: For finding out the name of the players (and send it to the lcd) and comunicating their average time for the game | ||
| + | * **I2C Protocol**: For showing the score, time, names on the lcd | ||
| + | </note> | ||
| ===== Rezultate Obţinute ===== | ===== Rezultate Obţinute ===== | ||
| Line 129: | Line 192: | ||
| 4 May 2026: Adding the block diagram. | 4 May 2026: Adding the block diagram. | ||
| + | |||
| + | 11 May 2026: Complete the hardware design. | ||
| + | |||
| + | 16 May 2026: Explaning the features of the game. | ||
| + | |||
| + | 27 May 2026: Finish the code for the project. | ||
| ===== Bibliografie/Resurse ===== | ===== Bibliografie/Resurse ===== | ||