WASD PTZ Control via Arduino of a Bescor MP101 Motorized Pan Head
parent
9d9802430e
commit
ce9d2ee4a3
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
wasd-ptz
|
||||
|
||||
WASD PTZ Control via Arduino of a Bescor MP101 Motorized Pan Head
|
||||
|
||||
Copyright (C) 2023, Jeff Moe
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// In main Arduino libraries
|
||||
#include "Keyboard.h"
|
||||
|
||||
char inChar;
|
||||
const int upPin = 1;
|
||||
const int downPin = 2;
|
||||
const int leftPin = 3;
|
||||
const int rightPin = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Keyboard.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available() > 0) {
|
||||
char inChar = Serial.read();
|
||||
|
||||
if (inChar == 'w') {
|
||||
Serial.println("Up");
|
||||
digitalWrite(leftPin,LOW); digitalWrite(rightPin,LOW); digitalWrite(upPin,HIGH); digitalWrite(downPin,LOW);
|
||||
}
|
||||
if (inChar == 'a') {
|
||||
Serial.println("Left");
|
||||
digitalWrite(leftPin,HIGH); digitalWrite(rightPin,LOW); digitalWrite(upPin,LOW); digitalWrite(downPin,LOW);
|
||||
}
|
||||
if (inChar == 's') {
|
||||
Serial.println("Down");
|
||||
digitalWrite(leftPin,LOW); digitalWrite(rightPin,LOW); digitalWrite(upPin,LOW); digitalWrite(downPin,HIGH);
|
||||
}
|
||||
if (inChar == 'd') {
|
||||
Serial.println("Right");
|
||||
digitalWrite(leftPin,LOW); digitalWrite(rightPin,HIGH); digitalWrite(upPin,LOW); digitalWrite(downPin,LOW);
|
||||
}
|
||||
|
||||
if (inChar == 'x') {
|
||||
Serial.println("Stop");
|
||||
digitalWrite(leftPin,LOW); digitalWrite(rightPin,LOW); digitalWrite(upPin,LOW); digitalWrite(downPin,LOW);
|
||||
}
|
||||
|
||||
if (inChar == ' ') {
|
||||
Serial.println("Stop");
|
||||
digitalWrite(leftPin,LOW); digitalWrite(rightPin,LOW); digitalWrite(upPin,LOW); digitalWrite(downPin,LOW);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue