JB's Electronics Club - Project #3

Mission: Build a functional game controller circuit that can be used with a block stacking game

How

  1. Build three basic switch circuits
  2. Connect the circuits to the Raspberry Pi
  3. Copy the game code into Thonny Python IDE
  4. Run the game code
  5. Play the game using the controller you’ve built

What you will need

  • 3x Switches (Push to make)
  • 4x Male to Female jumper cables (Black, Yellow, Orange & Red)
  • 3x Male to Male jumper cables (Black, Grey & Brown)

Part 1: Build three basic switch circuits

1. Place switch one so that two pins are in Column 6 & Column 8 of Row G, and the other two pins are in Row F of the same columns (The switch should sit over the groove in the middle of the breadboard)

2. Add a second switch, with the two sets of pins placed in Columns 17 & 19

3. Add the final switch so the pins sit in Columns 28 & 30

4. Connect the male pin of the black male to female jumper cable, into the first hole of the ground rail on the breadboard

5. Insert one end of the black male to male jumper cable into Column 6, Row L and the other end into the ground rail of the breadboard

6. Use the grey male to male jumper cable to connect Column 17 of Row L, to the ground rail

7. Connect Column 28, Row L to the ground rail, using the Brown male to male jumper cable

8. Insert the male end of the yellow male to female jumper cable, into Column 8, Row L

9. Insert the male end of the red male to female jumper cable, into Column 19, Row L

10. Insert the male end of the orange jumper cable into Column 30, Row L

Part 2: Connect the circuits to the Raspberry Pi

1. Connect the female end of the black Jumper cable to ground (between GPIO 18 & 23, 7th one in from the left)

2. Connect the female end of the Orange Jumper cable to GPIO 21

3. Connect the female end of Red Jumper cable to GPIO 20

4. Connect the female end of Yellow Jumper cable to GPIO 16

Part 3: Copy the game code into Thonny Python IDE

1. Open Thonny Python IDE

2. Download and copy the code from HERE into Thonny Python IDE

3. Save the code

4. Run the game and play using the controller

How the controller works:

The controller is made up of a series of switches, each completing a separate circuit when the controller is pressed.

When a completed circuit is detected by the Raspberry Pi, the code for the game executes a command within the game, to move or rotate the blocks, as instructed within the code.