1+ #include " Arduino.h"
2+ #include < Pelco_And_Arduino.h>
3+
4+ /*
5+ This exemple is based on the simple example from examples\simple\simple.ino
6+ However, it is designed for the old model of the Pelco cameras.
7+ The old models works in the protocol RS422 so it need 2 pair of cable to communicate.
8+ If you have only one pair (preferably for sending commands), you can disable acknoledge when sending commands
9+
10+ */
11+
12+ PelcoCamBus MyPelcoBus (6 , // TX pin (Arduino to Cam)
13+ 7 , // RX pin (Cam to Arduino)
14+ 8 ); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
15+
16+ void setup () {
17+
18+ Serial.begin (9600 );
19+
20+ // Begin the serial communication
21+ MyPelcoBus.begin (PELCO_D9600, true );
22+
23+ // Send stop, send_command will return a bool that indicates if the cameras sended its ACK
24+ // It's a good way to see if the camera is plugged in
25+ while (!MyPelcoBus.send_command (1 , STOP)) {
26+ Serial.println (" Camera not plugged?" );
27+ delay (1000 );
28+ }
29+ Serial.println (" Init Finished!" );
30+ }
31+
32+ void loop () {
33+
34+ // Pan to the left with max speed before turbo
35+ MyPelcoBus.send_command (1 , PAN_L, 0x3F , 0x00 , true );
36+ delay (1000 );
37+ MyPelcoBus.send_command (1 , STOP); // Stop the camera
38+ delay (1000 );
39+ // Pan to the left with less speed than the tilt speed that goes up
40+ MyPelcoBus.send_command (1 , PAN_L_TILT_U, 0x10 , 0xFF , true );
41+ delay (1000 );
42+ MyPelcoBus.send_command (1 , STOP); // Stop the camera
43+ delay (1000 );
44+ }
0 commit comments