Introduction: Hand Held Retro Game Station

Introducing the Handheld Gameboy, a nostalgic journey into the realm of classic gaming with a modern twist! This compact device brings the beloved retro experience of games like Space Invaders and Link to the palm of your hands, offering a blend of vintage charm and DIY ingenuity.

Powered by an Attiny 85 microcontroller, the Handheld Gameboy features an ingenious combination of components, including three push buttons, three 2.2k ohm resistors, one 330 ohm resistor, a buzzer, an OLED screen, and a 3V coin battery holder. This fusion of technology allows you to immerse yourself in the timeless joy of playing iconic games in a portable and handheld format.

Whether you're a seasoned enthusiast or a newcomer to the world of DIY electronics, the Handheld Gameboy invites you to embark on a journey of creation, nostalgia, and endless entertainment. Get ready to rediscover the magic of retro gaming in the palm of your hands!

Supplies

1, Attiny 85

3, Push buttons

3, 2.2k ohm resistors

1, 330 ohm resistor

1, buzzer

1, oled screen

1, 3v coin battery holder

Step 1: Programming the Attiny 85

Install Arduino IDE:

Download and install the Arduino IDE on your computer if you haven't already.


Set Up Arduino as a Programmer:

Connect your Arduino board to your computer via USB.

In the Arduino IDE, select the appropriate board model under "Tools" > "Board."

Choose the correct port under "Tools" > "Port."


Install Attiny 85 Support:

Open the Arduino IDE, go to "File" > "Preferences," and enter the URL for the Attiny 85 board support package.

Go to "Tools" > "Board" > "Boards Manager," search for "Attiny," and install the support package.


Select Attiny 85 Configuration:

Choose "Attiny 85" as the board under "Tools" > "Board."

Set the clock to "Internal 8 MHz" or the appropriate setting for your project.


Upload Code to Attiny 85:

Write or open your Handheld Gameboy code in the Arduino IDE.

Select "Burn Bootloader" to set up the Attiny 85 with the correct configuration.

Upload the code to the Attiny 85 using the "Upload" button.


Now that the Arduino IDE is set up for programming the Attiny 85, let's delve further into the programming process. Begin by ensuring that your Arduino board is connected to your computer via USB, allowing for a seamless data transfer between the two devices.

In the Arduino IDE, navigate to the "Tools" menu and select the appropriate board model under "Board." Choose the correct port for your Arduino board by going to "Tools" > "Port." These settings are crucial for establishing a reliable connection between your computer and the Arduino.

Moving on to installing Attiny 85 support, open the Arduino IDE and access the "File" menu. Select "Preferences" and enter the URL for the Attiny 85 board support package. This step is essential for integrating Attiny 85 compatibility into the Arduino IDE. Proceed to "Tools" > "Board" > "Boards Manager," search for "Attiny," and install the support package to make the Attiny 85 available as a target board for your programming endeavors.

With Attiny 85 support successfully added, choose "Attiny 85" as the board under "Tools" > "Board." Adjust the clock settings to "Internal 8 MHz" or the appropriate configuration for your specific project requirements.

To upload your code to the Attiny 85, either write your Handheld Gameboy code in the Arduino IDE or open an existing one. Select "Burn Bootloader" to configure the Attiny 85 with the correct settings, and then use the "Upload" button to transfer the code to the Attiny 85 microcontroller. This process ensures that your Attiny 85 is programmed and ready to execute the desired functionality for your Handheld Gameboy project.

Step 2: Set Up the Arduino

Prepare Arduino as Programmer:

  • Leave the Arduino connected to the computer via USB.

Verify Arduino Connections:

  • Double-check the wiring between the Arduino and the Attiny 85.
  • Ensure the correct selection of board and port in the Arduino IDE.


Leave the Arduino board connected to the computer via USB as you move on to the next steps. Before proceeding, verify the connections between the Arduino and the Attiny 85 to guarantee a secure and error-free data exchange.

In the Arduino IDE, double-check that the correct board model is selected under "Tools" > "Board" and that the appropriate port is chosen under "Tools" > "Port." These settings must align with your Arduino board for successful communication between the devices.

Step 3: Connect the Wires

Identify Pins on Arduino and Attiny 85:

  • Identify the corresponding pins on both the Arduino and the Attiny 85. The key pins you'll use are:Arduino: 5V, GND, RST, MISO, MOSI, SCK
  • Attiny 85: VCC, GND, RESET, MISO, MOSI, SCK

Connect Power (VCC and GND):

  • Connect the 5V output from the Arduino to the VCC pin on the Attiny 85.
  • Connect the GND (ground) from the Arduino to the GND pin on the Attiny 85.

Connect RESET Pin:

  • Connect the RESET pin on the Arduino to the RESET pin on the Attiny 85.

Connect MOSI, MISO, and SCK Pins:

  • Connect the MOSI pin on the Arduino to the MOSI pin on the Attiny 85.
  • Connect the MISO pin on the Arduino to the MISO pin on the Attiny 85.
  • Connect the SCK pin on the Arduino to the SCK pin on the Attiny 85.

Add 10μF Capacitor (Optional):

  • Optionally, you may connect a 10μF capacitor between the RESET and GND pins on the Arduino to stabilize the connection.


Ensure the Attiny 85 is correctly oriented, aligning pin 1 with the dot or notch on the chip. Verify the wiring and connections are secure before proceeding with programming.


Select Board:

  • In the Arduino IDE, go to "Tools" > "Board" and choose "Arduino as ISP."

Select Port:

  • Choose the correct port under "Tools" > "Port."

Burn Bootloader:

  • Go to "Tools" > "Burn Bootloader" to set up the Attiny 85 with the correct configuration.

Upload Code:

  • Once the bootloader is burned, you can upload your Handheld Gameboy code to the Attiny 85 using the "Upload" button.

Step 4: Making the Circuit on Wokwi (breadboard)

Pinout:

  1. SSD1306_SCL (Clock Line for OLED) - PORTB4
  2. SSD1306_SDA (Data Line for OLED) - PORTB3
  3. PB0 (Button for Player Fire) - digitalRead(2)
  4. PB1 (Speaker) - digitalWrite(1)
  5. PB2 (Button for Player Platform Movement) - digitalRead(0)
  6. RESET (Button for Game Reset) - analogRead(0)

Connecting Push Buttons:

  • Player Fire Button (PB0):
  • Connected to digitalRead(2) in the code.
  • No additional resistor needed if the button is connected to PB0.
  • Connect one terminal of the button to PB0 and the other to the ground.
  • Player Platform Movement Button (PB2):
  • Connected to digitalRead(0) in the code.
  • No additional resistor needed if the button is connected to PB2.
  • Connect one terminal of the button to PB2 and the other to the ground.
  • Game Reset Button (RESET):
  • Connected to analogRead(0) in the code.
  • A pull-up resistor is usually required for this configuration.
  • Connect one terminal of the button to the reset pin and the other to the ground.
  • It's advisable to use a resistor (around 10k ohms) between the reset pin and VCC.

Notes:

  • The code uses interrupts to handle button presses, particularly for PB0 (Player Fire) and PB2 (Player Platform Movement). Make sure your hardware setup aligns with the interrupt pin configuration.
  • The game initializes the OLED display (SSD1306) and sets up various game parameters.
  • The beep function generates sound for the game; you might need an external speaker connected to PB1.
  • The system_sleep function puts the ATtiny85 to sleep to conserve power when the game is not actively running.


Step 5: Free Form the Circuit on Wokwi

1. SSD1306 OLED Connections:

  • SSD1306_SCL (Clock Line for OLED) - PORTB4:
  • Solder a wire from PORTB4 on the ATtiny85 to the corresponding pin on the OLED.
  • SSD1306_SDA (Data Line for OLED) - PORTB3:
  • Solder a wire from PORTB3 on the ATtiny85 to the corresponding pin on the OLED.

2. Player Fire Button (PB0):

  • Solder one terminal of the button to PORTB0.
  • Solder the other terminal of the button to the ground.

3. Speaker (PB1):

  • Connect an external speaker to PORTB1.

4. Player Platform Movement Button (PB2):

  • Solder one terminal of the button to PORTB2.
  • Solder the other terminal of the button to the ground.

5. Game Reset Button (RESET):

  • Solder one terminal of the button to the reset pin.
  • Solder the other terminal of the button to the ground.
  • Connect a resistor (around 10k ohms) between the reset pin and VCC.

6. Notes:

  • Make sure the interrupt pin configuration aligns with the code's interrupt handling for buttons (PB0 and PB2).
  • Connect an external speaker to PB1 for generating game sounds.
  • Ensure that the OLED display (SSD1306) is initialized correctly, and necessary game parameters are set up.
  • Use the system_sleep function to put the ATtiny85 to sleep when the game is not active.

7. Verify Connections:

  • Double-check your soldering to ensure there are no short circuits or loose connections.
  • Confirm that the connections match the code's pin configuration.

Step 6: Make It IRL (in Real Life)

Now that you've made it to the end, have fun playing cool retro games!