Game controller with Arduino Leonardo

First version

: Make-through

This is my make-through for the week's assignment. Grab a cup of coffee!

PROCESS MAP

BACKGROUND (introduction about the project )

At the first week in advanced maker diploma, I will start from where i finished at Maker diploma 2021, i will design a low fediality of a game controller through cardboard and laser cutting then adding different electronics components in order to play with the game controller in two different modes( push buttons, Tilt sensor), i will pass through different stages in order to build this game controller


so let`s see this process........................

trim.mp4

The game controller without adding the 2 sensor, the hand and still practicing to play

OBJECTIVE #1: Doing a low fedaility prototype stage

Tools that i used at Doing a low fedaility prototype stage

glue


Sessicor


cardboard

white A4 paper


pencil


Trial #1 (Unsuccessful): Trying to figure out how to start

Step 1: Search

  • I started to search for examples for the game controller to figure out how to start

Step 2: sketch

  • then doing a quick sketch with a simple outline to know the dimension of the game controller and searching for the dimension of the components on google

Step 3: cardboard

  • after that try to create the prototype with cardboard, After I knew my dimension based on the electronics that I will use, I started to cut the cardboard with these dimensions, and do the joints between the sides based on these videos.

Step 4: Mount

  • then mount the component to make sure that the dimension is fine

Step 1

step 2

step 3 & 4

videos of step 3

videos of step 3

Trial #2 (successful): modify the first trial

at the mounting step, i discovered that the places that i left in the cardboard for components are too small, and i have to make it bigger.

Also, the way that i put the pushbuttons wasn't the perfect one for the user, it will confuse the user as it does not make sense where is the up, down, left or right buttons, so i replace it in the software stage.

the place where i will hold the game controller is to thin, i need to think to solve this.

Problem: i couldn't recognize the right dimension for the electronics even , and the interface of the

Potential Solution: the cardboard stage is a great solution to start with, before designing on the software and laser cutting in order to save your money and time

OBJECTIVE #2: software stage

Tools that i used at software stage

fusion 360 software


mouse


laptop

Trial #1 (unsuccessful): Designing on fusion 360

At the second session, Ahmed Ibrahim (the instructor) was explaining to us what is the kerf and how could we use it in our design, through creating a test plywood on fusion 360 then printing it on the laser cutting machine to test how we will design tabs and joints according to the kerf, and through this process, I understood that kerf is the width of material that is removed by a cutting process, its variable from a machine to other, and from time to time, so the only way of knowing the kerf of your machine is to test, and through the process that we had at the lab, we fabricate this piece of plywood and inserts in this whole a 3m plywood to discover which hole will fit the plywood in it without pressing hard or being losing, we did this process by fabricating many plywood and each time the kerf was different 0.01m, so the conclusion from this proces was (the kerf probably in most machines will be 0.2 which mean the it will be missing 0.2 from any cutting part in the machine).


  • Step 2: base

I already decided the dimension of the game controller from the last stage, so i started my design from the base side, which was for me the interface side that has the pushbuttons, then change the organizing of the buttons according to what i realized at the last stage, i started by drawing a rectangle then 4 triangles at the edges of the triangle then link these triangles with the line, fillet the whole sides and trim useless lines.


  • Step 3: the other 5 sides

then here, i added the remaining sides based on the scale of the central rectangle in the interface side, and the height beside on the height of the components.


  • step 4: joints (tabs & t-slots)

here i added the joints and tabs based on what i have learned about the kerf, for the t slot, i already was having the measurement of it from the maker diploma, so i did not draw it, i copied and paste it from previous projects, and for the tabs, i


grab cad it is a website to download the electronic components with different formats to know their accurate dimension, the 3 components that i have in this design are( Arduino Leonardo_tilt sensor_push buttons), so i searched for these components on the website with stp file format so fusion 360 could read it, i found a file for the push buttons but i could n`t find for tilt sensor, after that i uploaded the files to fusion then insert the 2 components into my design, i assembly the 2 components to their sides on the design then used the project tool to copy and paste the holes in the Arduino and the pushbuttons to fix the nuts and nails at these holes after fabrication.

step 4: create the tabs

  • Step 6: living things

I used a sheet metal icon to create the living hinges, then draw the rectangle in the sheet metal mode, then bend up this sheet at the points that i want, and use the flange mode to flatten again this sheet to be able to draw the pattern of the living things on it, by using the rectangular pattern icon.


Learning about the kerf at the session

designing the test plywood (custom kerf tool) to know the kerf at the laser cutting machine

Video show what is kerf

step 2: the base

this video will let you understand kerf in a simple way

dimension of push button

the back side that i will put by finger in this circle, so my hand will control the game controller well

  • Step 7: Extrude and assembly

after i finished the whole sketches, this the time of using the extrude icon and let the thikness will be 3m as i will fabricate with plywood 3m, then using the assembly icon to be sure that the whole sides are fits toghter.




Trial #2 (Successful): Modify first trial

  • Step 5: grab cad

as i couldnot a step file on grab cad for the tilt sensor, so i started to search for the dimension of the tilt sensor, to draw it and extrude, to be assembly at the place beside the arduino.

creating the tilt sensor then assembly it

dimension of the tilt sensor

OBJECTIVE #3: Digital Fabrication stage

Tools that i used at Fabrication stage

laser work software


laser cutting machine


playwood


Trial #1 (Successful): preparing the dxf file on the laserwork software to rld format

  • Step 1: convert Dxf file to Rld file

as i saved my sketch in a dxf format, so i still need to prepare the file on laserwork software so the laser cutting machine could read the file, i import the dxf file on the laserwork software to organize the parts beside each other to reduce consuming more plywood, then use delete overlap to make sure that there is no lines over laping in the desgin so the machine will not read many lines so the plywood maybe burn, the last touch is adjustment the speed and power parameters in laser work, and itis variable from a machine to another, so in fab lab it adjust (15 speed , 75 power) for cutting mood.


  • Step 2: send the file to the laser cutting machine

Now time for sending the file to the machine, so after i finished my setting in the laser work, so i opened the file on the pc that connected to the fab lab machine, and press download so the machine could read the file.


  • step3: prepare the laser cutting machine for fabrication

our machine still need an adjustment to start, we need to check if the focus is fine or not, by putting a piece of wood with thickness 6 cm under the laser pen and above the plywood sheet so the pen could touch it, and this space will be good for the laser beam to cut, then we will check the go scale from the machine or from laser work to check to reduce the consuming of the plywood, Now we could press Run.


Delete overlap tool

download and go scale button

fabrication time

Trial #2 (Successful): editing on the dimension after printing

after i finished the fabrication stage, the base and the 5 sides with successfully assembly with each other, but the living hings part and the back part weren`t fit together, i could recognize where is the problem in the back part through making the holes more bigger so it could fit my fingers, but for the living hings part, i still couldn't know howto fix it, i hope that i could have more time in the up comping week to reach for a solution

unsuccessful living hings

testing with my finger which one will be fits with my finger

the living hings suppose to be here

OBJECTIVE #4: electronics and wiring stage

Tools that i used at electronics and wiring stage

Fritzing software

nuts and nails

1 Arduino Leonardo


6 female/male jumpers


2 tilt sensor


Wire stripper

screwdriver


12 male jumpers


6 push buttons


Welding wire


soldering tool

Trial #1 (Successful): wiring on fritzing software

  • Step 1: Download Fritzing software

i tried to wire the components on tinker cad but i couldn't find the components on, instead i found the components on fritzing, so i download it, you will find a the last version from the software paid and the old versions will be free so choose which one you want.

  • Step 2: Download the missing components

After i download the software, i started to search for the components that i will wire them, i found the Leonardo Arduino and the push buttons, but couldn't find the sensor, so searched to download it, till i found this website.

  • Step 3: Wiring

After i got the program and the components, Now is the time for wiring, for the push button it has two pins, one will refer to the negative which i connect it with the ground on the Arduino-the black wire-, the other will refer to the positive which i will connect it to any digital pin on the Arduino (its not preferable to connect to o and 1 pins as it use for Bluetooth module)_the coloured wires-, then connect the sensor module, it has 3 pins, one refer to negative i will connect it with the ground pin on Arduino, the middle pin i will connect it to 5volt pin on Arduino, and the last one refer to the signal that i will connect it to the analog pin on the Arduino.

Pins of tilt sensor

Electronics Schematic

Trial #2(unSuccessful): wiring with the real components

  • Step 1: mounts the components with nuts and nails

I started to mount the components on the places that i left for them, then add the nails and nuts to fix them, i faced a problem to mount the tilt sensor as i found with me two different scale for the nail`s hole of tilt sensors as i attached below in the image, as i designed the hole with 3.20m diameter but one of them were their holes smaller than 3.20m, so i tried to find a suitable nail for it but i couldn't find so i replaced it with other suitable sensor.

  • Step 2: soldering

It was the first time for me to use the soldering tool, it was hard for me to control it and soldering, i was afraid from the heat and cannot handle it, i started by cutting the plastic wire of the jumper by Wire stripper tool to get out the copper wire, then adding the welding wire around the copper wire and the pin of push buttons to solder it by the soldering tool, but this process with unsuccessful to control the wire and the soldering tool.


  • step 3:wiring same like the wiring on the software

i already was wiring the ground and positive pins for the components on fritzing software before, so i wired it on real the same way , but i don't have a breadboard with me to connect the ground with each other so i solder the whole ground wires of the 6 push buttons with each other then connect it to ground of the Arduino, also i solder the ground of the tilt sensors with each other then connect it to other ground on the Arduino and reputed with the volt jumpers .



step 1: mount the components

step 1:adding the nails and nuts

step 1: the different between two sensors

soldering tool

soldering the wire with the pin of push button

make sure that it fixed

Trial #3(Successful): wiring with the real components

  • Step 2: soldering

As i mentioned above, i faced some trouble through soldering and cannot handle it in the right way, so someone suggested using the terminal, so i used it, i used the Wire stripper to cut the cover plastic wire in the jumper and link this copper wire inside one golden terminal, then i repeated the same thing to the other jumper, but I decided that i will not give up and i will find a way to solder again, till i found my collages at the diploma were soldering the terminal of the jumpers not the wire itself, and it was easy for my to do that, so i started by putting many layers from the welding wire around the jumper and the terminal of the push buttons, letting the jumpers direction being outside so the two jumpers will not touch each other through the soldering process as the circuit will spoil, then bring the soldering tool to solder this jumpers, then repeated this process for the reaming push buttons.

the terminals

putting the welding wire around the jumpers and the terminal of push buttons.

After soldering

Almost done for the whole push buttons

OBJECTIVE #5: coding stage

Tools that i used at coding stage

Arduino software


Cable for Arduino


Trial #1 (Successful): writing the coding

  • Step 1: Write the code related to the first four push buttons

this stage is always the most scary stage for me..........................

as i will play a game on the laptop with the game controller, so i will use the game controller instead of the keyboard on the laptop, therefore i will write a code to let the game controller manage the game instead of the keyboard, first i will start by including a library called Keyboard.h, i already found it on my software, then i will declare the first four push buttons as an input in the void setup with statement PinMode, because of using push buttons i will add pull up statement, i wrote Keyboard.begin statement with Arduino Leonardo to start emulating a keyboard connected to a computer, for the void loop i will use if condition, With the if statement, a program will execute the true code block or do nothing, With the if/else statement, the program will execute either the true code block or the false code block, also for adding above pull up statement so if i want to press on the button in real so i will write low, so i will write the statement if (digital read (5)==low) as i want to press on this button, in order to know which key i will use from my keyboard, i insert Keyboard.press functions as if a key were pressed and held on my keyboard, and choose which key i will add from the Keyboard.Arduino reference page then added delay in order to prevent a program from doing anything else until that particular task has completed, at last i used Keyboard.releaseAll To end the key press.

  • Step 2: then write the code of the reaming 2 push buttons

at this step i will repeat again what i did with the four buttons, but i will choose different buttons from the reference page, i used the else statement after i finished the code of the 6 letters.


the most exciting moments, testing the buttons by play super Mario, i was afraid that the soldering stage will not succeed but the buttons and the code was working.


  • Step 4: Write the code of tilt sensor


  • Step 5: Test the 2 sensors



step 4: tilt sensor code


step 1

step 1

step 1

step 1

step2: i wrote else, after i finished the code of the 6 letters

20220130_020518_1_1.mp4

Step 3: Testing the push buttons in crazy game website


in a case without adding Keyboard.releaseAll statment

i was testing the reading without adding the Keyboard.releaseAll so the helllo word was repeating till i unplug the arduino

this video will explain the concept of pull up with push button in a simple way

The whole code of the game controller

connect push buttons with the digital pins

and tilt sensors with analog pins

CONCLUSION: The project Almost done......

What I learned this week is...


  • keep trying and practicing is the only way to finish any thing you want to learn.


  • "Kerf" is a new magical concept that i knew at this week, i was suffering that the tabs and joints couldn`t fit with each other at my final project in maker diploma and i couldn`t know where is the problem, till i discovered at this week.


  • Even if your background is not related to coding or electronics, you could learn the basics of it by keeping searching and testing.


  • the result doesn't matter, the process is what matter.


20220130_020015_2.mp4