the idea:

Memory Mania is a two-person, ESP32-controlled Processing game which tests the strength of your memory! When going into this project, we wanted to make something that was a collaborative effort between two people but was also somewhat competitive (so it can be extra fun). Our brainstorming reminded us of that visual memory game or maybe Bop It?? where you are given a pattern, repeat it, and then that pattern grows until you fail to echo it accurately. As a result, Memory Mania was born.

the hardware

Since this project was split between the two of us, we pooled our ESP32 and hardware kits together. The two remote controls used by two different players each have a joystick, a button, and an LED light. One remote has blue buttons (Player 1), the other red (Player 2).

We ended up reading and writing output to and from two ESP32s plugged into a single laptop.

the code

Going into this project, we knew we wanted a visual component to the game - initially, we tossed around the idea of simply buttons controlling LED lights, but eventually, we ended up deciding that a virtual grid controlled via joystick and buttons would be more challenging and more enjoyable for players.

Having used Processing for the previous generative art module, we decided to stick with that language to create a fun GUI for our game. In the end, the structure of the code ended up being the Arduino code for the hardware, which fed joystick location data and button press information to Processing, which then ran our Processing code. Our processing code output a grid, the squares of which were highlighted when you hovered over them with the joystick. We also wanted to add another level of clarity via audio output, which manifested as a sound whenever a square was selected with the button and a different sound if it was the other player’s turn (there’s also a sad end screen with stats and a depressing noise when it’s GAME OVER).

Screenshot 2023-10-07 at 3.49.12 AM.png

Screenshot 2023-10-07 at 3.48.47 AM.png

the GUI and the end screen.

The following is our grid coloring function. RGB values are determined by whose turn it is currently.

void movePlayer(int x, int y, int sqX, int sqY, int r, int g, int b){ 
    for(int i = 0; i < sqX; i++) {
      for(int j = 0; j < sqY; j++) {
          if (i == x && j == y) {
             fill(r, g, b);   
         } else {
             fill(50);
         }
      }
    }
}

the enclosure

After scouring the CEID for some appropriately sized cardboard boxes, Maggie reused a package for rubber bands and Malia an empty box of Tazo tea. We first taped our circuit boards to a 4” x 3” cut piece of poster board. Maggie used a coffee cup sleeve for the ESP32 and board to stand on within the box. We reinforced the thin boxes with other thicker pieces of cardboard. We then cut out holes in the tops of each box and wrapped the enclosures like a Christmas present with black card stock paper and black electrical tape. Behold:

troubleshooting

One frustrating issue we had was the grid. It was at first confusing because the grid was created L to R, top to bottom—unlike a typical graph with x y data.

Another problem we ran into was reading input data from the joystick in Processing.

At first, we were having issues trying to compare data output from the ESP32 to Strings within Processing such as “R” or “L”. We realized it was a syntax issue when we were comparing values. Another issue was that our program was looping too often—so when we’d go to adjust the X or Y value of the current selected square, the values (noted as sqX or sqY) would cycle through 1-4 multiple times instead of moving just once. We had issues with random squares being highlighted, the entire grid being highlighted, etc.

To solve for this issue, we created a move(direction) boolean that tracks if the sqX or sqY value has already changed. The restriction is however that the joystick is limited to moving in a zig zag direction.