|
1 | | -## Pelco and arduino |
| 1 | +# Pelco and arduino |
2 | 2 |
|
3 | | -Library made for the purpose of this project: https://hackaday.io/project/183986-controlling-a-cctv-camera-with-arduino still in development! |
| 3 | +> Photography has nothing to do with cameras. |
| 4 | +
|
| 5 | + |
| 6 | + |
| 7 | +## Overview |
| 8 | + |
| 9 | +Hello, this is an Arduino library designed to control Pelco Cameras! |
| 10 | + |
| 11 | +For now it can support PELCO-D protocol but I havn't got tested everything yet. |
| 12 | + |
| 13 | +This library was made for the project: [Controlling a cctv camera on Arduino](https://hackaday.io/project/183986-controlling-a-cctv-camera-with-arduino) on hacakday.io |
| 14 | + |
| 15 | +Before you go on, this is a school, project, I'm still in school and learnings things so be kind if the libray is ugly. I would like to thanks my school and teachers for allowing me to work on this project. |
| 16 | + |
| 17 | +The main goal of the project is to do a control table (It'll be on arduino.) |
| 18 | + |
| 19 | +Anyway, here the table of contents: |
| 20 | + |
| 21 | +## Table of Contents |
| 22 | +- [Pelco and arduino](#pelco-and-arduino) |
| 23 | + - [Overview](#overview) |
| 24 | + - [Table of Contents](#table-of-contents) |
| 25 | + - [Requirements](#requirements) |
| 26 | + - [Exemple](#exemple) |
| 27 | + |
| 28 | + |
| 29 | +## Requirements |
| 30 | + |
| 31 | +This is a bit obvious but you'll need a Pelco camera, the one I use the ES4036. |
| 32 | + |
| 33 | +The important thing is to set the camera is RS485 biderectional and with the baud of your chossing. For now, the lib only support Pelco-D protocol. |
| 34 | + |
| 35 | +About the modules for RS485, I'm working with a standart MAX485 chip but I'll test a more advanced module on the future. |
| 36 | + |
| 37 | +## Exemple |
| 38 | + |
| 39 | +```arduino |
| 40 | + #include "Arduino.h" |
| 41 | + #include <Pelco_And_Arduino.h> |
| 42 | +
|
| 43 | + int Pan_position = 0; |
| 44 | +
|
| 45 | + PelcoCam PelcoCam(0x01, //Address of the camera |
| 46 | + PELCO_D9600,//Config |
| 47 | + 32, //TX pin |
| 48 | + 33, //RX pin |
| 49 | + true, //Enable logging? |
| 50 | + 25); //RE pin for manual switching modules |
| 51 | +
|
| 52 | + void setup() { |
| 53 | +
|
| 54 | + //Begin the serial communication If you enabled logging, no need to begin the normal serial |
| 55 | + PelcoCam.begin(); |
| 56 | +
|
| 57 | + //Send stop, send_command will return a bool that indicates if the cameras sended its ACK |
| 58 | + while (!PelcoCam.send_command(STOP)) { |
| 59 | + Serial.println("Camera not plugged?"); |
| 60 | + delay(1000); |
| 61 | + } |
| 62 | + Serial.println("Init Finished!"); |
| 63 | + } |
| 64 | + void loop() { |
| 65 | + |
| 66 | + //Pan to the left with max speed before turbo |
| 67 | + PelcoCam.send_command(PAN_L, 0x3F); |
| 68 | +
|
| 69 | + //send a request about the pan position |
| 70 | + Pan_position = PelcoCam.send_request(QUERY_PAN); |
| 71 | + Serial.println(Pan_position); |
| 72 | +
|
| 73 | + delay(1000); |
| 74 | + |
| 75 | + PelcoCam.send_command(STOP); //Stop the camera |
| 76 | + delay(1000); |
| 77 | + } |
| 78 | +``` |
0 commit comments