Simple Game Controller Using P5.serial Control

by mileslewis5280 in Circuits > Arduino

909 Views, 0 Favorites, 0 Comments

Simple Game Controller Using P5.serial Control

IMG_5598.jpg

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.

Wiring

Screen Shot 2021-05-24 at 11.11.45 AM.png
IMG_5599.jpg

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.

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.

Downloads

Arduino Code

P5.serial Control and P5.js

Screen Shot 2021-05-24 at 11.22.12 AM.png
Screen Shot 2021-05-24 at 11.27.04 AM.png

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

Play Test

Simple game controller using p5.serialcontrol