Step 3: Electronics
I placed a roll of transparent tape next to the Arduino in order to allow for the front panel to sustain pressure from the push buttons, as the casing has a certain depth to accomodate for the Arduino and the plastic casing is rather fragile in comparison to wood, cardboard or other types of plastic packaging. But anything with the right size and robustness goes.
Before soldering the buttons, make sure they are positioned in such a way that they will properly fit into the empty spaces on the front panel.
For each push-button, one side of the switch needs to be connected to the ground and the other one to one of Arduino's digital pins (here: digital pins 3, 5 and 8 for the cross button and the red ones, in that order - see code). No need for resistorsm, as floating values will be forced to "high" in the programming code.
Some isolating material might be need to separate the Arduino from the back of the circuit.
In terms of programming the micro-controller, it is assumed here that you are already familiar with Arduino and have the programming environment installed on your computer. If not, all you need to know is gathered on the Arduino resource page www.arduino.cc.
The code I used is the following:
int CrossButton = 3;
int RedButtonL = 5;
int RedButtonR = 8;
int val1 = 0;
int val2 = 0;
int val3 = 0;
void setup() {
pinMode(CrossButton, INPUT);
pinMode(RedButtonL, INPUT);
pinMode(RedButtonR, INPUT);
digitalWrite(CrossButton, HIGH);
digitalWrite(RedButtonL, HIGH);
digitalWrite(RedButtonR, HIGH);
Serial.begin(9600);
}
void loop(){
val1 = digitalRead(CrossButton);
val2 = digitalRead(RedButtonL);
val3 = digitalRead(RedButtonR);
Serial.print(val1, BIN);
Serial.print(val2, BIN);
Serial.print(val3, BIN);
Serial.println(",");
delay(10); // pause for 10 milliseconds
}
Remove these ads by
Signing Up























Not Nice














Visit Our Store »
Go Pro Today »



