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.img_9247We 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.
qq%e6%88%aa%e5%9b%be20161105001304Secondly, 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.aifileimg_9344Thirdly, I soldered the circuit components and arranged them in the enclosure. dsc07371dsc07364Finally, 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.

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

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

dsc07329The 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:
pinMode(buttonPin, INPUT);
pinMode(restartPin, INPUT);
pinMode(redledPin, OUTPUT);
pinMode(greenledPin, OUTPUT); // initialize the LED pin as an output
void loop() {
if (Serial.available() > 0) { // see if there's incoming serial data
// read the X axis:
int sensorValue = analogRead(A0);
// print the results:
// read the y axis:
sensorValue = analogRead(A1);
// print the results:
// read the z axis:
sensorValue = analogRead(A2);
// print the results:
//if the button is pressed
sensorValue = digitalRead(buttonPin);
sensorValue = digitalRead(restartPin);
incomingByte = Serial.read(); // read it
if (incomingByte == 'H') { // if it's a capital H (ASCII 72),
digitalWrite(redledPin, HIGH); // turn on red the LED
digitalWrite(greenledPin,LOW); // green LED
if (incomingByte == 'L') { // if it's an L (ASCII 76)
digitalWrite(redledPin, LOW); // turn off red the LED
digitalWrite(greenledPin, HIGH); // green LED