A Fun Little Embedded Project

Background: My roommates and I have been playing a game called Earth Defense Force 5 on PS4 together. The gameplay centers around destroying giant bugs (ants, spiders, etc.) and invading aliens. All of the equipment is obtained through random drops from enemies, including persistent armor boosts. I usually play as a character called an Air Raider who can call in air strikes and place auto-turrets.

One of my roommates and I were working on farming the armor boosts and weapons on a level where the enemies’ only attack is to roll at you, knocking you over and doing some damage. Individually, these enemies are really easy, just shoot them to knock them out of their roll, but when facing a group, the only way to stay on your feet is to get inside a building where they can’t reach, but you can shoot out. As an Air Raider, I usually sit near the entrance and throw turrets out the door.

The Problem: Throwing turrets out the door of a parking garage is very effective, and leaves you with a lot of extra time, but you have to replace the turrets every minute or so, so you can’t leave.

The Solution: Attach a micro-servo controlled by an arduino to the front of the controller. Have the servo deploy the turrets every 75 seconds and go do something else for a few hours while the loot piles up.

ControllerActuator[edit].jpg

Details: In EDF5, the fire/activate button can be held between reloads, and the weapon will fire/activate whenever possible (at least for some weapons, including turrets). I used a rubber band to hold down the fire button continuously. For turrets, the left bumper must be pressed separately each time to deploy them (the fire button throws a suitcase-looking thing out and the L1 button makes it unpack into a turret). I use the following code to move the servo:

#include <Servo.h>

Servo L1;

void setup() {
  L1.attach(3, 500, 2500);
}

void loop() {
  L1.write(10);
  delay(500);
  L1.write(0);
  delay( (75l * 1000l) - 500l);
}

The 75 is the number of seconds between attempted activation. Initially, I had it set to 10 seconds, but the servo was making noise while we were watching a movie, so I changed it to just larger than the time the turrets are alive + the time required to reload and throw them out the door.

As for the mechanical mount, I just cut the string off of a couple extra lanyards we had lying around. I was able to get it so that the controller can be used normally with the servo unplugged from the Arduino. This lets us get set up in the building before farming.

Summary: This project took about 1 hour for the first functioning prototype, though some tuning was done after. Most of that time was spent trying to get my instance of Code Composer Studio to work with the MSP432 Launchpad I had on hand (which I hadn’t used in a while). I then switched to another arduino which I believe has an electrical fault, and finally settled on the Arduino Uno. Getting everything working on the Uni took 20 minutes