This project by Aarón Montoya-Moraga consists of a webcam on servos that can be controlled from a Python script.
Modified by Sebastian Morales and Tiri Kananuruk
Developed for CW&T's Hardware and Sam Lavigne's Scrapism class, at School for Poetic Computation, Fall 2018.
This project was programmed and tested using the following software and hardware:
- Macbook running macOS High Sierra
- Arduino Uno
- Arduino IDE 1.8.5
- Python 3.6.3 (test on 3.6.3 but it also works on python 2.x. You need to commend someline in python code)
- pyserial Python module
- Arduino script to receive commands from the Python script.
- Python script to send commands to Arduino.
-
Clone or download this repository
-
Make sure you are using Python 3.x.
python --version-
Upload the script arduino_servo_camera.ino to the Arduino Uno.
-
Connect the servo motors to the Arduino.
pan servo(roll)
connect signal cable to pin 9 (pwm pin)
tilt servo(pitch)
connect signal cable to pin 10 (pwm pin)- Open terminal and go to the directory
cd Desktop/servo-camera- Install pyserial
pip install pyserial-
Open the Python script servo_camera.py
-
Update the arduinoPort variable if needed
arduinoPort = '/dev/cu.usbmodem1411'- If you are using python2, Delete .encode() out of the lines 32,36,40,44
ser.write("0,0\n")- Run the Python script on terminal
python servo_camera.pyThis script is making the camera infinitely loop through the sequence [0,0], [90, 90], [180, 180], [90, 90].