Tutorial for Python control of a camera mounted on a servo motor
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
arduino_servo_camera
pics
.gitignore
README.md
servo_camera.py

README.md

tutorial-servo-camera

02_final

About

This project by Aarón Montoya-Moraga consists of a webcam on servos that can be controlled from a Python script.

Developed for Sam Lavigne's Automating video class, at New York University's Interactive Telecommunications Program, November 2017.

Environment

This project was programmed and tested using the following software and hardware:

  • Macbook running macOS High Sierra
  • Arduino Uno
  • Arduino IDE 1.8.3
  • Python 2.7.10
  • virtualenv 15.1.0 Python module
  • pyserial Python module

Code

  • Arduino script to receive commands from the Python script.
  • Python script to send commands to Arduino.

Materials

Installation

python --version
  • Install the virtualenv python module
pip install virtualenv
  • Upload the script arduino_servo_camera.ino to the Arduino Uno.

  • Connect the servo motors to the Arduino.

00_connections

01_servos

Usage

  • Open terminal and go to the directory
cd Desktop/servo_camera
  • Initialize a virtual environment, call it env
python virtualenv env
  • Activate the virtual environment
source env/bin/activate
  • Install pyserial
pip install pyserial
  • Open the Python script servo_camera.py

  • Update the arduinoPort variable if needed

arduinoPort = '/dev/cu.usbmodem1461'
  • Run the Python script on terminal
python servo_camera.py

This script is making the camera infinitely loop through the sequence [0,0], [90, 90], [180, 180], [90, 90].

  • When finished, deactivate the virtual environment
deactivate

Bibliography