Punch Buddy


Intro

For my "Move" project I created a gauntlet that reads punching movements. When a punch is registered, it will cause the punching bag to be hit in game. An animation and sound effect will be played with each punch. With this project, my goal was to create a wearable device that a player could use to interact with a digital punching bag. I wanted the players punches to have differing effects on the punching bag based off of how they executed their punch. While I was able to somewhat meat this goal in the end, there was a major setback that resulted in the project becoming much simpler than originally desired. The resulting product is showcased in this video here:


How it works - Arduino

The main component of this project is the HC-SR04 Ultrasonic Sensor, a device that uses sonar to detect how close it is to a surface. For this iteration of the project, the sensor will simply detect when the gauntlet is within roughly 10cm of a surface to trigger a punch. This range will allow the player to trigger a punch by punching just in front of a surface (the prototype gauntlet is not strong enough to withstand any notable impact). When a punch is triggered, the gauntlet will be punch on cool-down for 0.42 seconds. This time frame seemed to provide the best experience while punching. It is short enough that consecutive punches will register, yet short enough so that the user wont punch so fast that the prototype gauntlet falls apart (once again, its not that strong).

The second component of this project are the two transistor powered LEDs. These simply covey the information of whether or not the gauntlet is on cool-down. While the LEDs are lit up, that means that gauntlet is off cool-down and the players punches will be registered. While the gauntlet is on cool-down, the LEDs will turn off briefly before rapidly flashing.


How it works - Unity

So how exactly is a punch registered into Unity? Through using Ardity, (a free open source Unity package), I was able to very easily setup basic serial communication via com port. This allows me to send messages back and forth between Unity and my Arduino device. For this project however, I only needed to read messages from my Arduino in Unity. When the Arduino registers a punch, it will send a "punch" message to Unity, where it then effects the digital punching bag. The "Punch Buddy" will play a basic animation of getting hit as well as pseudo-randomly play 1 of 4 different sound effects.


Process & Road Blocks

As mentioned in my video, I had originally wished to create a more complex project than I achieved. I wanted to create a 1-inch punch game that would measure how fast the punch was, then deal a different amount of damage based on how fast it was. Based on this damage, a bar of LEDs on the gauntlet would light up to display the power. In addition, the digital punching bag would display more exaggerated hit animations as well as play increasingly intense sound effect based on the punch's power. After I had coded all of the functionality for this however, I encountered one major issue, it didn't work. And I had no idea why. I had looked over the code and debugged for countless hours. Eventually, I discovered that the fault was not with my code, but with a physical component, the ultrasonic sensor. It had lost its ability to consistently read values below 10 cm (it was able to before). While this was very frustrating, all I could do was work around it.

In order to work within the capabilities of my sonar, I played around with the idea of having the Arduino be fixed in place rather than wearable. First I thought of making a sword swinging game, then of a shielding game. The sword game was a no-go for two reasons. First, the sonar didn't consistently pick up the disruptions caused by the sword swing. Second, the sonar was giving different readings for the same distance at seemingly random. The shielding game was scrapped because it seemed rather boring (attacking things is more fun). However, after doing all of these tests for game ideas, I finally managed to find something that my sonar read consistently. When getting close to a surface, the distance reading will always drop below a certain value whether it bugs out or not (the reading will drop to about 0cm when it gets around 10cm). With this knowledge, I decided to go back to creating a punching game, but more simple. I took the Cheez-It box I was using for a shield and transformed it into a gauntlet fit for holding my breadboard. All it took to build were some carefully placed cuts, a twist tie, and a rubber band.

 

Circuit Schematic

Links:

Arduino/Unity Code

Ardity 

Unity Audio Documentation

Sonar Setup

Comments

Popular posts from this blog

Red Light Green Light

Anime Opening Quiz