renn-the-dev / Embedded-Tetris

Building Tetris using an Arduino to escape the ads taking over my mobile game.
0 stars 0 forks source link

Research Hardware Components #4

Open renn-the-dev opened 1 month ago

renn-the-dev commented 1 month ago

Goal

Determine the minimum required hardware and schematic to build a functioning Tetris game prototype, preferably using majority pre-owned components. This stage should consider how these components will function together, the pins required to drive them, and the cost of acquiring additional hardware. Unfortunately, user experience is a distant third in this priority list.

With enough confidence, at the end of this ticket orders should be placed for the required additional hardware components.

Constraints

  1. The microcontroller will be the Arduino Nano. There are a limited number of GPIO and PWM pins available for use, which may require simplification of the hardware or proposed functionality.
  2. With the majority of pre-owned hardware components lacking associated datasheets, there may be unexpected hardware constraints or experimentally discovered hardware failings. Test the accuracy of assumptions where possible.

Recommendations

Display

  1. Gameplay - LED Matrix
  2. Score (pending schematic) - 4 Digit 7 Segment Display

Interactive Controls

  1. Moving the Tetrino - 4 buttons
  2. Adjusting the speed of a Tetrino (assuming it's possible to adjust clock speed) - potentiometer

Incidental/Stretch Hardware Requirements

Listed here

Schematic

<TBD, need to verify LED matrix functionality>

renn-the-dev commented 1 month ago

Gameplay Display

Recommendation

LED Matrix Board - $8.99 | Product Page | Datasheet

A 8x(8*4) grid of red LEDs that can be toggled on or off. Supports SPI communication. Clear datasheet, with accompanying example schematics. 2(?) dedicated pins required.

  1. Pros
    1. Should be simple to use, since there's no image rendering required.
    2. Super affordable.
    3. The correct width vs height for a Tetris game.
  2. Mid
    1. The Arduino may need to remember the state of the game and regen the board every time the code is run. Which means developing a purely software solution is likely going to be less throwaway work. Could even be used as a side-by-side comparison on my (currently theoretical) portfolio website.
      1. Nope - a skim of the datasheet shows we can rewrite individual pins. Which also implies we can read state, so depending on the software implementation, it could be a runtime decision.
  3. Cons
    1. Super simple display
      1. Limited reusability of the screen, since it's just dots. Could be some fun animations though, or maybe a music/volume wave? Weather chart? Actually could be pretty cool in it's simplicity...
      2. It would be impossible to display anything additional. To integrate score, etc. Would have to use external displays.
    2. It's a little unclear as to whether there'll need to be any soldering (I do not own a soldering kit).
    3. It's free-standing, and can't neatly clip itself to my breadboard, which could make this a messy project.
    4. I don't currently own this, which delays the development timeline and impacts financial practicality.

Alternatives

  1. One LED matrix block The line of four is probably overkill, in terms of the height of the Tetris game. However, I'm confident this kit requires soldering, which is not possible with my current toolset.
  2. LCD1602 Module from the Elegoo Super Starter Kit. I currently own it, however it's only two characters tall. Even turned on its side, that does not make an exciting Tetris game. While I can create custom characters for the Tetrinos, I couldn't make them fit together, as there's only the potential for eight additional custom characters using the Arduino library.
  3. LCD Display Screen Super versatile, and seems to have the display of a typical screen. However, it's going to take more pins, and I'd have to generate an entire image each time the board is rebuilt. Which could be a good extension, but graphic design is not the current trajectory of my embedded interests.
renn-the-dev commented 1 month ago

User Controls

Recommendation

4 buttons - pre-owned | Datasheet

Simple buttons, oriented to mimic upside down keyboard arrow keys. Simple GPIO. Four dedicated pins required. Left and right move the Tetrino. The center button rotates. The down button instantly drops the Tetrino.

  1. Pros
    1. I already own this :D
  2. Cons
    1. The buttons keep popping out of the breadboard, there's some trick I'm missing to keeping them in place.

Potential extension: A potentiometer to adjust the speed of the Tetrinos. Since there's no contrast control on the LED matrix, it could be easily repurposed for adjusting the clock speed, and consequently adjusting the speed of travel. Potential extension: A buzzer to notify the user when they've lost. Also coming as part of the kit it should be an easy extension, but not necessarily a priority. It would be easier to just code a losing animation, regardless.

Alternatives

  1. Joystick - pre-owned. This would require analog data collection instead of GPIO, and would require translation from a general direction to a function of the Tetrino. I expect this would be a worse user experience.
renn-the-dev commented 1 month ago

Additional Hardware Components

Pre-Owned

  1. Arduino Uno R3 (Elegoo brand)
  2. Jumper Cables Kit
  3. LEDs (for monitoring)
  4. USB cable (for loading code to arduino)
  5. Assorted resistors
  6. 9V battery (for independent usage)

To Buy

  1. Web server relay (potential stretch goal, would require investigation)