This is my make-through for the Module's assignment. Grab a cup of coffee!
In this module we should make a game controller that connected to computer to play a simple game...
Bill of material:
Arduino Leonardo
Push-Button X6
Tilt Switch Module (Mercury Switch) X2
Small breadboard (but I use I small PCB as a common ground)
I made a module using cardboard in the offline session and I put push buttons and Arduino and the two sensors in the card board module...
unfortunately, I didn't take a picture for the card board module... any way, it's the same design as in fusion
the following image is a sketch descripting the cardboard module... in card board module I put the Arduino and the two sensors in the bottom not in the top as in the CAD design
Step 1: Download all electronic parts and Import it to Fusion
Step 2: Design Faces
1) I start with the top face and then assembled the pus buttons and Arduino to it
2) then I design the two sides and the front and then the bottom
3) I make a rectangular face ro connect between the two sides and also to close the gap
Step 3: Join parts together
Step 4: Prepare sketches to export it as .dxf files... for front and bottom faces I just calculate the curves radii and get the perimeter and then design the living hinge
Step 5: Export all faces as dxf files
Step 1: open all the exported dxf files in laser works.
1) remove all extra line that exported from fusion (dash and center lines).
2) make all lines to cute with high power and low speed.
Step 2: write my name.
make the name with different color to be scanned.
here you can notice that I write my name upside down :)
Step 3: delete overlaps and preview the process before downloading it to the laser cutter machine
Step 3: send it to the laser cutter.
step 4: assemble with screws and nuts.
Step 1: Wiring components to gather
First I make a common ground. I cut a small PCB and make holes for jumpers using a hand drill. connect push buttons and the two sensors to the PCB (common ground)
Then wired the push buttons and the two sensors to Arduino as shown
The two sensors should be in opposite direction to each other as shown in order to work properly... when tilt left one sensor will read high and the other will read low... and when tilt right one will read low and the other will read high... when it's horizontal the two sensors will have the same readings
PCB as common ground
Step 2: Coding
In setup function I defined the output pins for Arduino and I make pins from 2~7 for push buttons and pins 8 & 9 are for the sensors...
It should be defined as INPUT_PULLUP to be able to read low when the pushbutton is pressed.
In loop function the whole code is based on if statement... and I didn't use else if for pushbuttons because usually we press to buttons together, Up & Left for example. So, it's better for push buttons not to use else if.
for sensors logic I used else if statement as the two sensors control only one direction (Right or Left) and it's impossible to go right and left at the same time...
Because the two sensors are in opposite direction to each other, when tilt left one sensor will read high and the other will read low... and when tilt right one will read low and the other will read high... when it's horizontal the two sensors will have the same readings
What I learned this week is...
I learned more in CAD design in fusion, and knew how Arduino Leonardo works and how the computer may read it as a keyboard.
One thing can be done by many ways... I find many cool ways to design the game controller sharing ideas with my teammates
Arduino Leonardo
Sheet metal design in fusion
Sharing Idea is the best way for best result.