|
12x12x7.3mm Momentary Tact Tactile Push Button |
x 8 | |
|
Push Button |
x 7 | |
|
Raspberry Pi Pico |
x 1 | |
|
Generic D1286464 OLED Display |
x 1 | |
|
Joystick Module PS2 |
x 1 | |
|
10 kohm resistor |
x 15 |
Raspberry Pi Pico Gamepad
Raspberry Pi Pico-based programmable gamepad.
Steps to create:
1. PCB Designing
a. Download the source from https://github.com/aviralverma-8877/raspberrypi-pico-gamepad
b. You will find the eagle board and schema files under PCB_design directory.
c. You can also download the Gerber files in the same directory as Pico Gamepad.zip.
d. Upload the Gerber zip to the PCB Way for manufacturing.
e. Once you will receive the PCB you can proceed to the next step.
2. Components
a. 12x12x7.3mm Momentary Tact Tactile Push Button
b. Push Button
f. Generic D1286464 OLED Display
3. Assembly
a. The PCB you will receive from PCB way will have all the components marked on the silkscreen with the corresponding GPIOs they are connected to.
b. Make sure you position the components correctly and solder them well.
c. To cross verify you can use a multimeter to test the connectivity.
d. Once fully assembled, the PCB should look like the one mentioned in the project images.
4. Programming
a. Connect the raspberry pi pico to a PC.
b. If the raspberry pi pico is new you can skip the next step.
c. Download the flash_nuke.uf2 file from raspberry pi pico official website, and flash the Pico with the same.
d. Download the circuit python from the Adafruit website and flash it onto the raspberry pi pico.
e. Once circuit python is flashed, you will find the circuit python drive under This PC or My Computer.
f. Copy and replace the entire content of Pico Gamepad directory from the project git page onto the circuit python drive.
g. Once replaced, you will see the display on the OLED screen.
5. Functionality
a. By pressing the mode button, you can switch between Gamepad -> Mouse -> Media Controller.
b. OLED display will also show the currently active mode.
c. In the gamepad mode, all the buttons are assigned to their corresponding functionality.
d. In mouse mode, you can use the joystick to control the pointer and use the start and select button for right and left-click.
e. In the media controller mode, you can use the gamepad to control various functions such as volume control, next/previous track, play, and pause, etc.
f. Keys can be reprogrammed by editing the buttons.py file.
6. Code Analysis
The whole project is available at GitHub. You can either clone or download it from there. The micro python code is available under Pico Gamepad directory.
Circuit python is built to target beginners and young programmers, so the code for our raspberry pi pico is very simple and easy to understand. The entry point for the code is code.py.
code.py
The code.py will import all the libraries and components of the project, create their objects and initialize them with appropriate values. For controlling mouse + gamepad +media, we are using Adafruit's HID library.
Initialize them:
and then move the pointer to the center.
After this, we are creating the object of button.py, which is the main engine of the project.
First by importing it:
Then by initializing it:
We are also setting the text of the OLED display to Welcome just for the user to see the welcome message.
Then the main method "record()" is called, which will start an infinite loop to listen to the button presses.
button.py
The constructor of the button.py will set all the button GPIOs, set their directions to pulled up, set the joystick, and set the OLED Display.
show_text() method is used to display text on the OLED display. The font size is set to 1.
This method will first fill the screen with black, show it on display, then Type the text with the default OLED color, and then show it on display.
range_map() method is used to calculate the pixel to be moved, based on the joystick movement. This method is used for both mouse and gamepad movement.
The record() method is the method with an infinite loop where all the functions related to the gamepad + mouse + media are defined.
In the loop, we are checking using if conditions, which button is pressed, and what functions need to be performed. For example:
if the button UP is pressed, Then we will check in which mode currently the user is in.
If mode==1, means the user is in gamepad mode, then the gamepad button 1 is pressed by calling gp.press_button(1) (where gp is the object of gamepad).
if mode==0, means the user is in media mode, then the button press will increase the volume.
if mode==2 means the user is in mouse mode, in that mode only start and select buttons are assigned to the left and right-click.
Finally at last, for a joystick, we are checking the mode for mouse or gamepad, and accordingly setting the movement by calling and determining the range_map() method.
The mode is altered by pressing the mode button, between mode = 0,1,2
Since the whole source code will be saved on the MCU flash memory, we have kept the variable size and comments to be minimum, to save memory.
7.3D Printing
If you own a 3D printer then you can print the gamepad base by downloading the Pico Gamepad Bottom.stl under 3D Prints directory.
You can use 4 M.2 screws to fit the gamepad PCB to the 3D printed base.
Raspberry Pi Pico Gamepad
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(3)
- Likes(12)
- Engineer Oct 01,2024
- Engineer Sep 14,2024
- Jaime Ortiz Apr 23,2024
- craftermath Jul 20,2023
- Engineer Jul 17,2023
- Duane Watson Jun 30,2023
- BatDetectorReviews May 22,2023
- Engineer May 12,2023
- Matthew Beeston Jun 14,2022
- (DIY) C64iSTANBUL Jun 03,2021
- KushagraK7 Jun 03,2021
- ElectroMaker Jun 03,2021
- 3 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
10design
-
10usability
-
10creativity
-
10content
-
9design
-
7usability
-
8creativity
-
8content
-
9design
-
8usability
-
9creativity
-
9content
More by Aviral Verma
- Helical Antenna for GOES/GK-2A weather satellite reception. General Theory:Usually when someone thinks about satellite communication first thing that comes to m...
- Raspberry Pi Pico Gamepad Raspberry Pi Pico-based programmable gamepad.Steps to create:1. PCB Designing a. Download the source...
- Project Voyager This board combines an ESP32 microcontroller with an RA-01 LoRa module. It serves as an alternative ...
- Nokia 5110 hat for Raspberry Pi The Raspberry Pi Clock Hat is a versatile accessory that transforms your Raspberry Pi into a powerfu...
- Raspberry Pi Pico Radio Pico radio is a simple raspberry pi pico based FM receiver that uses rda5807m to tune to FM channels...
- IoT Connect IoT Connect is an open-source IoT platform built on top of esp8266, which allow users to connect an...
-
-
Micro Planck - 3D Printable Low Profile Mechanical Keyboard
162 1 0 -
Corazon LED intermitente
54 0 0 -
-