Introduction: Simple Game Controller Using P5.serial Control

About: skateboarder, student, maker

This project explores serial communication from Arduino to p5.js using p5.Serialcontrol. Using p5, I made a game controller with digital inputs to play a simple Asteroids-type game. The game is not finished but the basic control and feel of the game is achieved. I modeled my game after this tutorial https://www.youtube.com/watch?v=hacZU523FyM.

Supplies

Button

Slider

Potentiometer

LED strip

Arduino nano

umper wires.

Step 1: Wiring

Connect all wires to Arduino as shown. I used an Arduino nano and a mini breadboard. I also ran out of 5v spaces and had to solder two wires together. Also, the schematic shows two potentiometers, but I used a slider instead.

Step 2: Building the Enclosure.

build an enclosure for the electronics with plenty of room for the Arduino. I laser cut mine but any type of enclosure works. Cut holes for all other electronics and install them through the back. Plug the wires into the breadboard and glue components with hot glue. I left the back of the box open with tape so I can fix it if any wires come undone.

Step 3: Arduino Code

Step 4: P5.serial Control and P5.js

I'm using the 5.serialcontrol app to send serial data from Arduino to p5.js. to start connect the controller to the computer and select the right port in p5.serialcontrol. click connect. Next copy my code in p5 and run the code. The game is a simple asteroids-type game to show the inputs work in real-time. Here is the game: https://editor.p5js.org/milestheplatypus/sketches/0gkbUJXkb

Step 5: Play Test