I worked with Shivanku Kumar for the Pcomp Midterm Project. We made a 2D ball game, which looks like this:

Shivanku Kumar designed the game by P5. The code can be seen here. I wrote the code in Arduino and made an enclosure for the remote control. We solved lots of problems together. I also learnt from Shivanku about how to debug and check the code step by step.

The processes are as follows.

At first, we used Arduino UNO and bread board to make a prototype.We checked the four output values in serial monitor: the x,y and z values of the triple-axis accelerometer, the digital output values of the buttons.
Secondly, I draw the enclosure’s sketch for laser cutter in Illustrator. The size of the box is about the same as iPhone 6, which is comfortable to hold in hands.Thirdly, I soldered the circuit components and arranged them in the enclosure. Finally, we connected the remote control box with the computer. We tested every functions, which worked very well:

1. Using the triple-axis accelerometer to control the ball’s speed on x-axis and y-axis.
2. Using the black button in the right top corner to start a new game. The button is not big, because it’s not being used frequently. But the position is easy to reach by the thumb of user’s right hand.
3. Using the big pink button to control the barrier’s speed. I setted the core button at the position where the user’s thumb can easily reach to, but it won’t bother people when it’s not needed.
4. Using a green led to indicate that the game is going on well, and turning on a red led when the game is over.

The two pictures above show that the green led is on when the game is going well.

The two pictures above show that the red led is on when the game is over.

The score showing on top of the screen encourages people to paly the game.

Here is the video of playing the game with the remote control box. I like the game very much. It’s simple but attracts me to play time and time again.

Here is the code in Arduino:

```const int buttonPin = 2;
const int restartPin = 7;
const int redledPin =4; // the pin that the LED is attached to
const int greenledPin = 8; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// configure the serial connection:
Serial.begin(9600);
pinMode(buttonPin, INPUT);
pinMode(restartPin, INPUT);
pinMode(redledPin, OUTPUT);
pinMode(greenledPin, OUTPUT); // initialize the LED pin as an output
}
void loop() {
if (Serial.available() &gt; 0) { // see if there's incoming serial data
// read the X axis:
int sensorValue = analogRead(A0);
// print the results:
Serial.print(sensorValue);
Serial.print(",");
// read the y axis:
// print the results:
Serial.print(sensorValue);
Serial.print(",");
// read the z axis:
// print the results:
Serial.print(sensorValue);
Serial.print(",");
//if the button is pressed
Serial.print(sensorValue);
Serial.print(",");