Skip to content

chrisfejiro/Robotic_Arm_with_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Robotic Arm with Arduino Uno using python

This project uses OpenCV and cvzone to track hand gestures from a webcam and control a servo motor connected to an Arduino board. The servo moves based on the number of fingers detected as "up."


Features

  • Detects fingers raised using a webcam.
  • Controls a servo motor on Arduino through serial communication.
  • Simple gesture-based servo positioning:
    • All fingers up → servo rotates to 0°.
    • All fingers down → servo rotates to 180°.

Requirements

  • Python 3.9+
  • Arduino board (e.g., Uno, Mega)
  • Servo motor connected to Arduino pin 9 (PWM pin)
  • Libraries:
    • OpenCV
    • cvzone
    • pyfirmata

Installation

  1. Clone this repository or download the files.

  2. Create a Python virtual environment (optional but recommended):

    python -m venv env source env/bin/activate # Linux/macOS .\env\Scripts\activate # Windows Install dependencies:

pip install opencv-python cvzone pyfirmata Connect your Arduino board and upload the standard Firmata sketch:

Open Arduino IDE

Go to File > Examples > Firmata > StandardFirmata

Upload to your board

Connect your servo to Arduino pin 9.

Modify the controller.py file if your Arduino COM port is different from 'COM4'.

Usage Run the main hand tracking script:

python main.py The webcam will open and detect hand gestures.

The servo motor will rotate based on finger count.

Press k to quit.

Files main.py: Main script for hand tracking and video feed.

controller.py: Arduino servo control logic using pyfirmata.

Troubleshooting Make sure the Arduino is connected and Firmata firmware is uploaded.

Close other programs accessing the COM port.

Use Python 3.9 for compatibility with some dependencies.

Update pip if you get errors: python -m pip install --upgrade pip

License This project is open source and free to use.

Acknowledgments cvzone for easy hand tracking.

pyfirmata for Arduino communication.

About

A python code to work with Arduino

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages