Skip to main content

Ball Game using Accelerometer & Arduino

 


 Project Proposal PDF : Armball Mania Project Proposal

I was recently experimenting with serial communication between Arduino and ue4 and suddenly had this urge to make a fun sensor controlled game. Something different and intuitive !

Now, I remember that I had the ADXL from my previous project which had become one of my favorite sensor ! - and I knew exactly what to do. I know, I know. Why am I using an accelerometer ! Using a gyro would've been a better idea. And you're right, That's the intuitive part ! 

 

The Arduino Part

Before everything, I needed to test if it even works. So, I created a demo project, where I would control the pitch yaw and roll of a flat rectangular object with live inputs from the sensor which Will be in the users hands. Serial communication was a bit tricky. And I needed to open and close the ports dynamically so that I can change it on the go. After a bit of tweaking, I got it to work !

To summarize the protocol in English, Ue4 would scream to the Arduino through the open tunnel and then Arduino would bundle and send back all the data together as a response. And of course, I had to unpack the data later. This happens over a 1000 time under a second, giving us a latency free experience. 


 


Now, before everything. I needed a system in the middle that would filter and smooth out the sensor data to give us a butter like experience, thus I played around with some algorithms and got that done with. But, even with the smoothing - this felt a bit janky and was popping all around, here and there. That's because the accelerometer interprets even the slightest torque from my hand, thus the noise like output ! So, I had to program in a noise reduction system. - that would only allow a certain expected range of change around the present base value. And that actually solved quite a lot of the problem.

 

 

Now, I was going for a game that could be controlled with hand movements. Thus I needed something to attach the hardware with the user's hand, for ease of use. Instead of them just holding it.
So, I got a brand new latex glove and sowed the hardware on it - in a more sci-if way. And lastly, I made sure to make it look cool ! With this sorted out, I programmed in a round object, that would simulate realistic physics and bounce around like a real life ball. And although, things were just starting off at this point - it was possible to balance the ball and keep it in a steady position.

This, although simple - was a fun game on it's own. We could spawn the ball on command and watch it interact with the cube. Simulating, realistic physics ! And. Man, the glove was cool AF. Cutting the fingers was a good idea after-all. It made it so much better ! At this point, the base system was almost ready. Just needed to develop the full fledged game and decorate it !

 

The game development part
So, From here. It's all software stuff !
Which is a good thing because you'll get some insight on my workflow in game design. Now. Two things I needed to get started was, A ball and a football field. I modeled the field with all it's individual parts and imported it at first in ue4. What I had in mind was a 90s retro game but with a dash of modern aesthetic as the basic accent of the visual and design.

So, I wanted the field markings to glow brightly. Which was a good decision because it made the user more aware of the structure of the field and the goal posts. I added to the field structure and design inside of ue4 and it looked really great ! Now, things were looking kinda dark and not properly visible. So, I worked a lot on the lighting and the backdrop. To give it a soft moody aesthetics ! A little bit of fog, some soft lighting and some glow.

With this done, I experimented with the ball a lot.
I made it out to glow red, tried to put a arrow on it's head and a lot more. But at last settled with a red cricket ball ! I brought it in and with it's texture done, I replaced it with our initial spherical object.
( Now, the goofs were about to come ! How about this, I'm going to give the player an option to pick between a ball - seems reasonable, a toy pony and a torus ) That would certainly help spice things up !




And, oh. The ball would emit a red light to make the Player better understanding it's location. The light dynamically interacting with the floor and bleeding off to volumetric looked so trippy. I almost forgot how painfully setting up the camera or was. I tried to make it react to the ball movement but it had some serious drawbacks, which I better not get into at this moment. But, Making it static was so much better, specially when the control for changing it, was with the players !
There was a total of 3 camera angles at this point which was custom made by me. And they could choose any one of it !

There was a short moment where I experimented with some wall variations around the field. So that the ball doesn't fall off. But, later discarded the idea since it would've made it a lot easier ! Okay, now let's get back to lighting and the aesthetic part ! I made two studio light and brought in into the map ! It would hang above the goal post and shed some buttery smooth green light on it. Man, the volumetric made it look so cool ! And it was dynamic. Score a goal and it would change its color to red !
Also, I needed to destroy the old ball object, spawn a new one and increment the current score. Which brings us to the particle effect !

Now, ue4 provides fantastic tools for visual effects. Which helped me a lot to create the particle systems. This world spawn when the ball spawns in the middle of the field and when the player scores a goal ! A little bit of explosion, some magic. That added a lot of impact !

 

 
 



Wait, it's not done yet !
It took me days to get the UI up and running.
Since I was making everything up from scratch, it took a lot of time and effort. I needed to be able to control the sensitivity, noise reduction and the ports all from the UI ! So, the main menu and the pause menu was to be made. If the port is abandoned, I needed to close it and stop the game. The appropriate message should be displayed and the user should have the ability to open the port back again manually and that would automatically resume the game - all while Making it look good !





After the pause menu was made and working, I wanted to make the main menu dynamic. I thought of having a modeled human hand floating and reacting live to the sensor, so that the user can see their changes to the parameters - live on screen.
And of course I had to work on the lights to make it look beautiful.

 


Guess what's next ?
The sound design. We needed spawn and score sound effects and different background music - all to be custom made !
After giving it some final finishing touches. It was in a presentable position ! Lastly, I would color grade to tweak the look and feel of the game ! And also fixed some bugs.
With everything done, I finally exported and built the game ! Here's the showcase of the whole thing !

Now, the whole project which includes the game, the Arduino code and the instructions is uploaded in game-jolt. For anyone to try it out. Here's the link : Click here

 

Here is the full video log of the development journey !


How to use ?
Before you get started, there's some basic things you must do to set this up: You would need an accelerometer of course which is an ADXL345 module and you need to connect it with an Arduino.  Now for this project you just need to hook up the SCL and the SDA pins from the module with that of the Arduino along with the VCC and ground. That's it after you are pretty much done with the hardware part. The code will handle the rest. So, you need to upload the code which is provided with this project into your Arduino.

 



Now, on your PC or laptop, open the game and you'll be greater with the main menu where you can change some parameters. For starters leave the first two as is ( the functions are pretty much self explanatory ) but ! You need to look up through which port your Arduino is connected to your PC and sent the correct port here on the main menu.
Now, Press the big white burn button - that should start everything up and if you have connected everything up properly, it should work wonderfully !
So, press the start game button and you're in.

Here are some shortcuts that might be useful for you : Press B to change the ball type, you can press the space-bar or the I button on your keyboard to spawn in a new ball. And, you can use C to change the camera angle ! Lastly use the ESC key or P on your keyboard to pause the game and access the pause menu ! Where you can find all of these options again !

Now, talking about the game, it's pretty self explanatory. Just pass the ball through one of the two goal posts, and you've scored !

 

 Here is the video tutorial and instructional video !

 


 

Click here to visit the game page at Gamejolt. Have fun !


 Presenting ArmBall Mania at the National Exhibition September, 2022


Me and Sayanti Chatterjee Presenting the ArmBall Mania at the 75th National Exhibition at the Science Fair Salt-lake. On September 2022.

 

 




Insane response from the Youth at the Exhibition. Here are some video clips.








Comments

Popular posts from this blog

A Multipurpose Mini Desktop Assistant Robot

       We have named it 'Cookie Bot' 🍪 Cookie Bot is a multipurpose mini desktop assistant robot that you can control with your voice when needed but also has a mind of its own ! It uses a combination of AI, Machine Learning, and speech recognition to control its movements and actions based on different situations and surroundings. Users can interact with the robot through voice commands and its voice assistant artificial intelligence system allows it to detect and understand user commands in different natural languages including English and Hindi !  Cookie Bot acts lively, moves around on its own using a path finding algorithm to navigate and avoid obstacles while responding to different commands from the user. The Cookie Bot uses a LIDER sensor to detect objects in its path and a Ultrasonic sensor to sense objects and objects in its surrounding environment. Here's a video of the first working prototype : Prototype 1 : December 15th, 2022 Prototype 1 : Projec...

Search and Rescue Deployable Assistant

   The Project Proposal Objectives : The future calls for a safer, more efficient, and reliable habitable environment for everyone throughout the globe - an attack, accident, and disaster-proof infrastructure with zero casualties in such events. But if there are any, we need to have the technology and resources to combat such situations. SARDA is a deployable robotic unit intended to help first responders in such crucial situations to carry out search and rescue operations in dangerous environments.  When deployed into the disaster site, it helps to map and render a dynamic color coded 3D model of it's immediate surrounding along with data like temperature and humidity ; Which, not only aids the rescue team to better navigate the terrain but also informs us in case of fire and smoke along with it's exact location. This digital twin can also be overridden with manual control, providing us with an efficient two-way communication system. The Deploy-able unit ...

Morse code Broadcaster App & Receiver using Arduino

Me and Sayanti Chatterjee had been working on this for over a month now.  This was really an ambitious project and we tried to pull off something big ! The app takes in a string of words - encodes it into Morse code and broadcasts it in form of light pulses using the phones flash light in accordance with both of the frequency parameters. Changing those parameters changes the speed of the broadcast. On the other end there's a Arduino with a photo-resistor which keeps sleeping and wakes up only when senses the first light pulse. ( So, basically it's a auto on/off feature ) which receives and reads those light flashes, processes it and decodes it into it's original form. ( Again, in accordance with those parameters ) Displays it and goes back to sleep ! This is how wireless data transfer works ! It's just a simplified form of a WiFi or a cell tower. We've recreated a model wireless communication system from scratch !  What is the most important skill that you can have...

Robotic Shooter Game • From DIY to Unreal Engine 5 Masterpiece!

Previously, when we showcased our initial project at the national science fair, we presented "Armball Mania," a novel and intuitive sensor-controlled game. This project utilized an accelerometer connected to a compact Arduino Nano, with serial communication enabling the transfer of orientation data to an Unreal Engine game. The game's objective was to balance a ball on a football field and score goals by manipulating the field's orientation with the accelerometer mounted on a DIY glove worn by the user. The project was a hit at the fair in Kolkata, drawing long lines of enthusiastic students and children eager to experience the game. Despite the success, we encountered significant challenges with the accelerometer. The sensor's sensitivity to minute hand movements caused jittery and unstable outputs, making the gameplay less smooth and precise than desired. To overcome this, we decided to upgrade to a gyroscope. The gyroscope provided a remarkable improvement in a...

Homemade 2-axis gimbal using Arduino

  I present to you the cheapest camera or object stabilizer in the whole world ! A 2-axis gimbal that keeps an object steady in a certain position despite the movement of the base on which it is mounted. This means when the base keeps changing its position constantly, the object will remain stable and there won’t be any change in its position. It all started with my new ADXL345 and I thought to myself why not try and build a hand-held gimbal at home since these things are rather costly out there. So, I fired up max and as usual started working on the digital prototype or the blueprint. I had a few servos left from the previous project that I worked on and two of them were enough for this simple stabilizer. And I have learnt from my mistakes ! Knowing that these servos won't be able to put up with so much, I designed the frame in a way that would fairly distribute the load away from the motor. With all this in mind, I roughly designed the whole thing and tried to make i...

DIY Contactless Mist Sanitizer

  Today I'm going to show you how I turned a broken pocket mist generator into: A Contactless Mist Sanitizer Machine  in just one day. Sounds cool, right? Let's get started ! First, let me explain what a pocket mist generator is. It's basically a device that sprays a fine mist of liquid, usually water or sanitizer, to moisturize or disinfect your skin or surroundings. It's handy and portable, but mine stopped working after a few months of use. So I decided to open it up and see what's inside. To my surprise, I found out that it doesn't use any heating element or pump to create the mist. Instead, it has a tiny diaphragm that vibrates at a very high frequency, around 100 kHz, and breaks the liquid into tiny droplets that form the mist. This is called ultrasonic atomization, and it's very efficient and quiet. I wanted to control this diaphragm using my Arduino Uno, but I couldn't generate such a high frequency with it. So I had to use the origi...

DIY LiDAR SLAM Robot from Scratch

    Showcase & Documentary  1. Deep Learning Based Calibration  2. ICP Based Odometry & Positioning (Manual)  3. Path-Finding using A* Algorithm & Traversing (Manual) 4. Automatic Navigation & Path-Finding 5. Complete Autonomus Navigation With Feedback Loop  Download Vagabond:  https://github.com/Kawai-Senpai/Vagabond/ Welcome to this exciting exploration into the world of SLAM—Simultaneous Localization and Mapping. Most people working on SLAM typically rely on Robot Operating System (ROS) and predefined libraries, using simulations instead of real-world scenarios. But we decided to take a different route. We believed that if we wanted to truly master SLAM, we needed to do it the right way—from scratch. Rather than using pre-built templates and libraries, which can be picked up at any time, we challenged ourselves to build a SLAM system manually. Now, we didn’t have the budget to buy a professional LiDAR sensor, which can be quite expen...

Miniature Remote controlled Robotic Arm

    A remote controlled cute little miniature version of a robotic arm which can sit on your table and pick up your eraser when you drop it. I've always been fascinated by Industrial Robotic arms. They are so simple yet complicated ! And I wanted to try and make one from the ground up without any help. Kind of wanted to simplify it and work with what I got. Planning At the moment, I had only two servos and 1 stepper motor. So, I needed to build the whole thing with nothing but those. So, I fired up Max and started working on the blueprint.     It's like a prototype that I like to create virtually - Which give me the Idea on How the real thing should be built ! And also, I can change stuffs easily here if things dont work out and improve the overall model if I need to. So, I found a way to create a cute little robotic mechanical arm with only the things I got. This would be able to pick up things with the help of that mouth and move ut around. Pretty simple...

AI-Powered 6-DOF Robot in Unreal Engine

      Waste management has become one of the most pressing issues of our time, and innovative solutions are needed now more than ever. What if we could blend the precision of robotics with the power of AI to create a system that not only automates waste segregation but also bridges the gap between virtual simulations and real-world applications? In this documentary, we’ll take you behind the scenes of a groundbreaking project: the development of a 6-degree-of-freedom robotic arm designed for waste segregation, all simulated within the immersive environment of Unreal Engine. The journey began with the idea of creating a robotic arm that could mimic human movements with high precision. To achieve this, we focused on developing a 6-degree-of-freedom (6-DOF) system, allowing the arm to move in any direction, rotate, and grasp objects as efficiently as a human hand. But building this complex system wasn’t just about mechanics—it was about crafting a seamless interaction betwee...