Skip to content

Commit 4b4bf0f

Browse files
ptzfirm.ino
1 parent cf356f4 commit 4b4bf0f

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

ptzfirm.ino

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ String inputString = "";
2222
bool stringComplete = true;
2323

2424
bool status = false;
25+
bool gstat = false;
2526

2627
void setup() {
2728
Serial.begin(9600);
@@ -55,6 +56,16 @@ void get_sensor_data() {
5556
}
5657
}
5758

59+
void geigar(){
60+
if (gstat){
61+
int mSv = analogRead(A1)
62+
Serial.print("$GEI(");
63+
Serial.print(mSv, 2);
64+
Serial.println(")");
65+
}
66+
67+
}
68+
5869
void control_ptz(String cmd) {
5970
if (cmd.length() < 2) return;
6071

@@ -91,7 +102,7 @@ void control_ptz(String cmd) {
91102
} else if (direction == '1') { // tilt (positional servo)
92103
Pos2 += value;
93104
Pos2 = constrain(Pos2, 80, 165);
94-
Serial.print(Pos2, 2); //meow
105+
Serial.print(Pos2, 2); // meow
95106
servo2.write(Pos2);
96107
}
97108
}
@@ -109,19 +120,29 @@ void serialEvent() {
109120
}
110121

111122
void loop() {
112-
if (stringComplete) {
123+
if (stringComplete) {a
113124
inputString.trim();
114125
Serial.print(inputString);
115126
if (inputString == "sensor_on") {
116127
status = true;
117-
} else if (inputString == "sensor_off") {
128+
}
129+
else if (inputString == "sensor_off") {
118130
status = false;
119-
} else if (inputString == "stop_pan") {
131+
}
132+
else if (inputString == "geigar_on"){
133+
gstat = true;
134+
}
135+
else if (inputString == "geigar_off"){
136+
gstat = false;
137+
}
138+
else if (inputString == "stop_pan") {
120139
digitalWrite(3, LOW);
121140
digitalWrite(5, LOW);
122-
} else if (inputString.charAt(0) == '0' || inputString.charAt(0) == '1') {
141+
}
142+
else if (inputString.charAt(0) == '0' || inputString.charAt(0) == '1') {
123143
control_ptz(inputString);
124-
} else {
144+
}
145+
else {
125146
Serial.println("Invalid command.");
126147
}
127148
inputString = "";

0 commit comments

Comments
 (0)