Self playable game on smartphone

Hardware

I recently assembled a Lego phone holder that rotates along the Y-axis (the longer side of the phone). The holder's end is attached to a servo motor, which is connected to an Android smartphone via USB OTG through a motor module. This motor module can control up to 24 servo motors and operates at 5 volts.

Software

The motor module has its own built-in protocol, which handles rotation and speed, with parameters separated by newline characters.

The second part of the project involved developing an Android application to communicate with the servo module using this serial protocol. I based the application on an example of USB serial communication with Arduino, adapting it to work with my device.

Game

For this project, I chose a game I developed about a year ago. It's a simple game where the accelerometer controls a rocket that must navigate through gates. Tilting the device left or right adjusts the rocket's position, and the goal is to pass through as many gates as possible. The rocket's speed increases with each gate passed.

Steps

Initially, I aimed to detect the maximum rotation values for both directions and use these values to dynamically adjust the holder's rotation. However, after making several modifications to the holder's construction, I realized that the configuration varied slightly each time. To address this, I implemented a calibration method that runs at startup, automatically detecting the limit values. During gameplay, these values are recalculated to ensure accurate control. For a clearer understanding, please watch the video below.

Result

While the practical use of this "self-playable holder" may be limited, it serves as a valuable exercise in connecting an Android device to a servo motor. It provides a useful introduction to integrating hardware control with Android applications.


You can find the source code here: 

https://github.com/mbodis/lgg3_qc_rocket_studio/tree/usb_servo
















Comments

Post a Comment

Popular posts from this blog

Skate Tricks Recognition Using Gyroscope

Play table

Counting dice and train wagons using computer vision