An Android app that uses Google's MediaPipe to detect hand landmarks in real-time and control a physical bionic arm via USB serial communication. Transform your hand movements into precise servo control for robotics projects.
- Real-time hand landmark detection using MediaPipe
- Finger position calculation as percentages (0-100%)
- USB serial communication to Arduino
- Live connection status with visual indicators
- Camera switching between front and back cameras
- Automatic Arduino detection and connection
- Real-time finger position display in UI
- Screen stays on during operation
- 5-finger servo control via Arduino
- PCA9685 PWM driver support for precise control
- Smooth movement interpolation to reduce jitter
- Calibrated servo ranges for optimal performance
- Emergency stop functionality
- Connection timeout handling
- Android device with camera
- Arduino Uno + 5 servo motors
- USB OTG cable
- PCA9685 PWM driver (recommended)
- Clone the repository
- Open in Android Studio and sync Gradle files
- Upload Arduino code from
arduino_inmoov_app_ready/folder - Wire servos according to setup guides
- Build and run the Android app
- Connect Arduino via USB OTG cable
- Arduino Uno (or compatible)
- PCA9685 16-Channel PWM Driver
- 5 Servo Motors (SG90, MG996R, or similar)
- USB OTG Cable
- External 5V Power Supply (3-5A recommended)
- Jumper wires and breadboard
Arduino β PCA9685:
5V β VCC, GND β GND
A4 β SDA, A5 β SCL
PCA9685 Channels:
Channel 0 β Thumb Servo
Channel 1 β Index Servo
Channel 2 β Middle Servo
Channel 3 β Ring Servo
Channel 4 β Pinky Servo
For detailed wiring diagrams, see:
- BIONIC_ARM_SETUP.md - Basic Arduino setup
- PCA9685_SETUP_GUIDE.md - Advanced PCA9685 setup
- Launch the app - Grant camera permission when prompted
- Connect Arduino - Tap "Connect Arduino" button
- Grant USB permission - Allow access to Arduino
- Show your hand - Point camera at your hand
- Watch the magic - Bionic arm mimics your movements!
- π’ Green checkmark = Arduino connected and ready
- π Orange warning = Arduino not connected
- Live percentages = Current finger positions (0-100%)
MainActivity.kt- Main activity with permissionsHandLandmarkDetector.kt- Main detection composableCameraPreview.kt- Camera integration with MediaPipeHandLandmarkOverlay.kt- Hand visualization overlayFingerPositionCalculator.kt- Converts landmarks to percentagesUsbSerialManager.kt- Arduino USB communicationImageUtils.kt- Image processing utilities
arduino_inmoov_app_ready/- Production-ready InMoov hand controllerarduino_servo_calibrated/- Basic servo controlarduino_servo_calibration/- Servo calibration toolsdirect_servo_test/- Individual servo testingi2c_scanner/- I2C device detection
// MediaPipe for hand detection
implementation("com.google.mediapipe:tasks-vision:0.10.8")
// USB Serial communication
implementation("com.github.mik3y:usb-serial-for-android:3.7.3")
// Camera functionality
implementation("androidx.camera:camera-core:1.3.1")
implementation("androidx.camera:camera-camera2:1.3.1")
implementation("androidx.camera:camera-lifecycle:1.3.1")#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>The app sends finger positions to Arduino via USB serial:
Format: T:XX,I:XX,M:XX,R:XX,P:XX\n
Where:
- T = Thumb (0-100%)
- I = Index finger (0-100%)
- M = Middle finger (0-100%)
- R = Ring finger (0-100%)
- P = Pinky (0-100%)
Example: T:45,I:78,M:82,R:65,P:23\n
MediaPipe detects 21 key points per hand:
- Thumb: 5 points (landmarks 0-4)
- Index finger: 4 points (landmarks 5-8)
- Middle finger: 4 points (landmarks 9-12)
- Ring finger: 4 points (landmarks 13-16)
- Pinky: 4 points (landmarks 17-20)
Edit ranges in Arduino code:
ServoRange thumbRange = {400, 2200}; // Min/Max pulse width
ServoRange indexRange = {400, 2200};
// ... etcAdjust mapping in FingerPositionCalculator.kt:
// Remap finger ranges based on your hand
val remappedIndex = map(indexPos, 50, 99, 0, 100)- β Check USB OTG cable functionality
- β Verify Arduino is powered and code uploaded
- β Grant USB permissions in Android
- β Try different USB ports/cables
- β Ensure good lighting conditions
- β Keep hand clearly visible in frame
- β Try switching camera (front/back)
- β Clean camera lens
- β Check servo wiring and power supply
- β Verify PCA9685 I2C connections
- β Test servos individually with calibration code
- β Adjust pulse width ranges for your servos
Use Arduino Serial Monitor:
testServos() - Test all servos
calibrateServo(0) - Calibrate thumb servo
emergencyStop() - Stop all servos
- Multiple hand detection (currently uses first detected hand)
- Custom gesture recognition (extend FingerPositionCalculator)
- Different servo types (adjust pulse width ranges)
- Smoothing parameters (modify SMOOTHING_FACTOR)
- BIONIC_ARM_SETUP.md - Complete hardware setup guide
- PCA9685_SETUP_GUIDE.md - Advanced PWM driver setup
- WIRING_DIAGRAM.txt - Detailed wiring information
- External Power: Use dedicated 5V supply for servos
- Current Limits: Don't exceed Arduino's current capacity
- Mechanical Limits: Set appropriate servo angle limits
- Testing: Always test components individually first
Contributions welcome! Please read the setup guides and test your changes with actual hardware.
See LICENSE file for details.
Ready to build your own bionic arm? Follow the setup guides and start controlling servos with your hand movements! π¦Ύ

