This web page contains a disclaimer/license, a brief discussion concerning evolution of this "Gamepad-Arduino-OTG-Android" subsystem, a set of references, and a collection of helpful details. Additional details are provided on Page 2.
1> No warranty is made regarding the servicability or fitness for use of this Gamepad-OTG subsystem.
2> A user may employ, enjoy, or engage in this project under the terms of he GNU General Public License (GNU GPL or GPL) as
OpenSource software licenses that guarantee end users the freedom to run, study, share, and modify the software. All
copyrights privildeges are reserved.
The goal of this project was to provide a gamepad style user interface that could communicate via the Android as a front-end for remote control of the squirrel-chase vehicle.
The working assumptions are:
This project concluded by demonsrating the feasibility of controlling a ground mobile vehicle using a
"Gamepad style navigation" over OTG with an Android device serving as Host. It also demonstrate feasibility
of Compass style navigation Android app for controlling the same vehicle. Finally it demonstrated that the
Android could transmit/receive vehicle motion control data bundles WIFI UDP access point to effectively
control a vehicle.
Link to first Road Test 200927
Link to second Road Test 201005
Link to third and final Road Test 210103
The original vision for this project to provide a user front-end of a second generation squirrel-chaser. The first generation of squirrel-chaser employed an Arduino driven vehicle which was controlled via WiFI from an Android tablet. Initial testing of the first generation squirrel-chaser produced a static run video video and a active motion test video. But producing these two videos quickly demonstrated the "need for a user control interface" that support a "gamepad" style user interface, UI.
The first order criteria for fulfilling that "need" quickly focused on a gamepad component UI front-end connected to an Android tablet. A second order criteria was the utilization of material/components already on hand. The third order criteria was to employ the MIT App2Inventor development, A2I, platform for the Android. This criteria allowed the re-use of the work already successfully completed during the first generation of the squirrel-chaser.
The initial solution suggested using the available Logitech F310. The Ubuntu PC operating system had two drivers, xboxdrv and xpad, available to support the F310. Also there is a host of applicaations that data could readily be transferred. That solution was discarded after painfully learning that there was no OpenSource driver available for the Android. It was determined that de-engineering of the available drivers was feasible. But although feasible there was a very high risk due to the learning curve of the tools involved.
Looking around the lab/shop suggested that there was at least one alternate solution. That first alternate solution included an Makeblock Orion Inventor Electronic Kit (UNO board, joystick, potentiometer, rj25 adapter board), an available OTG cable, Arduino prototype boards, test clips, etc.
After gathering and assembling the components for the proposed first solution the focus of the project's effort returned to the "driver". A possible solution was found the the A2I's Serial component and the OpenSource Arduino.aix extension. But it was discovered that both entities were essentially the same sketch and relied upon the Physicaloid driver. Separate attempts to re-use these two entities were made. Both support only turning LED's on and off at the Android end. Neither readily supported moving a data package for processing.
Fortunately, an example was found that demonstrated that data packages could be transmitted over the OTG to the Android. The example employed the USBSerial driver. The example was re-used on the "proposed solution assembly of components" and satisfactorily demonstrated "gamepad UI" potential. However, the example and the "re-used" versions were built using the Android SDK Studio. The "example-USBSerial" approach was de-engineered and re-generated using the mit-cml/extension-template authored by ewpatton.
The resulting solution provides a level of satisfactory project maturity. At this level of maturity that permits the data capture of joystick movement, speed control, and command buttons and transmission that data the the target Android tablet. The technical details leading to the solution are given below in the Project Details section.
![]() |
APK as shown running on an Android tablet was developed via MIT A2I which relies upon the Arduino.aix extension. The Extension depends upon the Physicaloid.jar USB communication driver/library. See the Serial component available from MIT A2I packaged as com.google.appinventor.components.runtime.Serial.java for the design boilerplate/template for using the Physicaloid driver. | ![]() |
Gamepad Hardware Assmbly:
Gamepad Code Elements of Solution: (As Of 201005) Project repositiory contains:
Command | Comment |
dmesg | provides detail information about components/devices managed by the kernel. |
lsusb | list the various usb devices. Logitech, Inc. F310 Gamepad [XInput Mode] |
lsinput | list all input devices |
lsmod | generates a list of active modules. "0" indicates not used. |
lsmod | grep xpad | looks specifically for xpad module |
ls -l /dev/input/js0 | Response: crw-rw-rw-+ 1 root input 13, 0 Aug 7 15:38 /dev/input/js0 shows js0 is available to members of input group |
qjoypad --device /dev/input & | starts an gamepad session |
cat /dev/input/js0 | Displays Raw gamepad traffic for js0 |
jstest-gtk | Displays axis/buttons of gamepad devices for mapping and calibration |
sudo xboxdrv {--silent} | starts driver if not already active. flip switch on bottom to X run xbox driver. |
sudo xboxdrv --detach-kernel-driver | never used |
sudo service xboxdrv stop | halts the xboxdrv service and removes events & js* from /dev/input. |
sudo service xboxdrv restart | starts ubuntu-xboxdrv |
sudo cat /sys/kernel/
debug/usb/devices |
Confirms xpad loading of gamepad |
sudo rmmod xpad | shuts-down the xpad mode |
cat /proc/bus/input/devices | list devices |
sudo service joystick restart | default gameport module/service |
sudo modprobe xpad | starts the xpad module |
lsmod | grep xpad | list xpad and dependent modules |
cat /etc/group | verify input group exists |
ls -l /dev/input | obtain a list of input devices that are installed |
sudo xpad status verbose | confirm xpad is active |
sudo usermod -a -G groupName userName | add user to a group. Need to restart session |
cat /etc/group | verify input group exists |
members input | check to see who is in group |
cat /dev/input/js0 |xxd -g 2 -c 8 | Displays the characters reflecting F310 play/press |
python parser_main.py | Displays the button & stick parse hex values.
cd /media/tom/Silo_002/TechWork/DIY_projects/p006_squirrelChaser/011_gameport/001_grub/F310_Gamepad_Parser-master |
{Ctrl}z from cmd prompt | stops python instance of parser_main.py |
http://ai2.appinventor.mit.edu/your_account_number | URL: log-in to my workspace at MIT app2inventor |
adb logcat | From Ubuntu cmd line for log |
GTK-Term Port Configuration:
==>>/dev/input/js0 |
Displays USB as Byte Traffic Packages.
GtkTerm at 9600 Parity None Bits 8. Hex set view: Hexadecimal and Hexadecimal Char 8 |
adb logcat | View the android's logcat file from Ubuntu with USB and adb
{ctrl}z halts {ctrl} s stops scroll |
./doa2i_local.sh
==>> URL: http://localhost:8888 |
bash script in ~/ for executing ./java_dev)appserver.sh |
./java_dev_appserver.sh | Google Cloud SDK/bin/
arguments: java_dev_appserver.sh --port=8888 --address=0.0.0.0 /media/tom/Silo_002/TechWork/appinventor-sources/appinventor /appengine/build/war |
ant | from /media/tom/Silo_002/TechWork/appinventor-sources/appinventor
to build a new app2Inventor |
ant extensions | To fire-up the a2i Extensions Tool from a terminal locate and navigate to
the target folder: i.e cd /media/tom/Silo_002/TechWork/appinventor_tool4extesnionsl/g038_999_gamepad_otg_serial Then enter the ant command with its option as shown. |
sudo Nutty. Then set for wireless and devcies | Network utility for viewing devices status and information. See Ubuntu version download site or use Ubuntu Software to install "nutty". No longer works due to system changes on my specific PC.
![]() ![]() |
sudo wireshark | Download and run WireShark to monitor WiFi-UDP communication in near real time.
![]() ![]() |
Spare | Spare |
OTG Details The android's OTG, On-The-Go cable is different than the USB-C. The OTG is a five USB micro to a 4 pin USB-A male/female. The USB-C is a connector with 24 pin double-sided connector. But both the OTG and USB-C support Dual-Role-Data (DRD) ports. A Dual-Role-Data (DRD) devices detects whether it is to have a host or client role.