Final project of the summer

So I’ve wrapped up my final project of the summer. During the pandemic, I’ve been brushing up on my electronics and learning how to use the Unreal Engine to create video games. I wanted to see if I could tie those two ideas together. Watch the video below to see how it’s possible to create a video game that requires you to know what is going on in the physical world. In this case, the color of an LED connected to a microcontroller informs the gamer which colored sphere to shoot.

As I’ve done with my other UE4 tutorials, below are the blueprints in case you are interested in building your own project.

This event goes into the Game Mode and is used to make the VeRest API calls. (Full size)
The Sphere actor takes care of collision logic. If a sphere is hit by a projectile, it checks to see if it was supposed to be hit and rewards/penalizes the player as appropriate. (Full size)
Game Mode has a few extra events to set timers, the initial LED color, and check to see if the game is over. (Full size)

Below is the microcontroller code.

/*
 * Project ue4-lights
 * Description: Tutorial for UE4 communication
 * Author: BoBthechemist
 * Date: 8/16/2020
 */


int ledArray[] = { D2, D3, D4 };
int which; 
int randomLED(String args) {
  // Options for args are none, red, blue, green, black
  if( args.equals("red") ) {which = 0; }
  else if( args.equals("green") ) { which = 1; }
  else if( args.equals("blue") ) { which = 2; }
  else if( args.equals("black") ) {which = -1; }
  else { which = random(3); }
  // Turn off all LEDs
  for(int i = 0; i < 3; i++) {
    digitalWrite(ledArray[i], LOW);
  }
  // Now turn on the LED we want
  if (which >= 0) {
    digitalWrite(ledArray[which],HIGH);
  }
  return which;
} 

void setup() {
  // Set LED pins to output
  for(int i = 0; i < 3; i++){
    pinMode(ledArray[i], OUTPUT);
  }
  Particle.variable("led",which);
  Particle.function("changeLED", randomLED);
  which = randomLED("");  
}
void loop() {
  delay(25);
}

2 thoughts on “Final project of the summer

    • This was done with a particle Argon. I’ve moved away from that platform and am now using Adafruit with their Adafruit.IO service, as that is easy to use via CircuitPython or the Arduino IDE.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.