This is my make-through for the week's assignment. Grab a cup of coffee!
I am making a joystick controller that is composed of 6 buttons that can be used to play arcade games such as Super Mario and Pac-Man.
This joystick is inspired by the Super Nintendo Controller.
The joystick controller I am making supports PCs only. It has 2 modes: Button Mode and Tilt Mode.
Button Mode: This mode allows the user to control the game by pressing buttons.
Tilt Mode: This mode allows the user to control the game by tilting the controller.
First of all the Push Button that will be used will be the is the tactile switch. This button is reliable because of its low cost, dimensions, and ease of use.
The tactile switch will be mounted on the PCB. The cap will be mounted from the enclosure's top face for the user to press the buttons.
The second component is the ATTiny85. It is the most reliable microcontroller currently in this iteration in terms of cost, availability. and size.
ATTiny85 can be programmed using Arduino through Digispark's Bootloader
The main reason ATTiny85 is used over other available tiny microcontrollers is its Hardware User Interface feature, which allows the computer to recognize the microcontroller directly as a recognizable USB Device and can control both the computer's Keyboard and Mouse.
This is due to that the Digispark Interface is designed to communicate directly with the computer. It features a library "DigiKeyboard.h" that allows us to bind Keyboard Presses in the code.
This will be useful in binding the pushbutton presses to Keyboard actions.
The KYO-17 contains a single digital output pin and features moving mercury such that its movement triggers internal switches that can be read through a digital pin.
The position of the mercury decides the output of the signal pin, and from the signal pin, we can read it and know the tilt position.
This sensor will be placed inside the controller for the Tilt Mode.
Before starting any project, a proof of concept phase is necessary.
The first phase of any prototyping process is Cardboard Prototyping.
The second phase is the Lasercut Plywood Prototyping where we have successfully created a functioning prototype with Arduino Leanardo on a plywood enclosure.
The power circuit includes a
USB circuit for powering up the system and Serial Communication
a LED to be used as a power indicator
Zero Ohm Resistors for bridging GND and 5V signals
a decoupling capacitor used for filtering out noise from the circuit.
The I/O circuit includes
two pin headers for each tilt sensor
6 resistors in series with 6 buttons acting as voltage dividers. Each button pressed will give a different voltage that appears to the analog pin connected to the ATTiny85, thus the software will be able to differentiate between the 6 button presses on a single analog pin on the microcontroller.
The ATTiny85 pins are connected to the I/O circuit and the USB circuit.
ISP Comm pin header will be a direct terminal used when uploading the Digispark Bootloader to the board.
This is the outline that is close to the Nintendo joystick drawn on Fusion 360 that will be imported to Autodesk Eagle as the outline of the PCB.
The components were placed according to their desired position in the enclosure.
A ground plane was created using a polygon and Ratsnet.
Zero ohm resistors were used for bridging ground signals.
This is the outline that is close to the Nintendo joystick drawn on Fusion 360 that will be imported to Autodesk Eagle as the outline of the PCB.
The design of the joystick controller will be a mixed enclosure between acrylic (Laser Cutting) and PLA (3D Printing).
The top and bottom faces will be fabricated using laser cutting with the acrylic material.
While the complex sides and curve will be fabricated using 3D printing.
The PCB design was exported to Fusion 360.
an offset was added for the sketch, and then the side was extruded.
The top and bottom faces were created
Holes were created for the screws, USB, buttons, and LED.
Button Caps were designed.
Unfortunately there is no footage of the 3D printing.
On the right is the footage for the laser cutting process for the top and bottom faces
Step 1: Define all GPIO Pins and configure internal pullup resistors.
Step 2: Bind Keyboard to Pushbuttons
Step 3: Use Delays to bounce off buttons
Step 4: Map Tilt Sensors to Keyboard Controls
Step 5: Switch between modes
The mechanism of the code is rather simple.
I execute the action in each loop according to the mode we are in (Line 33 and Line 53)
I bind each button press to an analog value. These lines are for button mode (lines 32 to 50)
Lines 53 to 65 are for the tilt mode
Lines 56 to 57 and 49 to 50 are for switching between tilt mode and button mode
The delay at line 65 is for debouncing the button presses.
Joint the bottom face to the PCB
Attach the bottom face to the 3D printed side body
Attach the top face to the 3D printed side body
Insert the buttons in the top face
Finally!
The joystick is finally ready.
It has 6 pushbuttons, just as planned.
The gesture mode was not implemented, I will implement in the next iteration.
I have tested it on PacMan, and it works like charm.
The video is in the conclusion section.
What I learned this iteration is...
Designing PCBs and creating complex circuits
Creating complex designs for mixed enclosures and snap fits.
I am very proud that I have created a far more complex design than the one in iteration 1. You can see the joystick from iteration 1, how big it is compared to the joystick from iteration 2. This reflects a large progress in the project's lifecycle