![]() When the button is released the conditional if is not entered, so the servos stay in their last positions and the joystick can be released. #Pan tilt usb camera with iguard codeYou put all the pot/servo code in a conditional IF statement such that when the button/trigger is pushed the if statement is entered and the servos are positioned. ZoomServo.write(zoomVal) //move servo to required positionĭownVal = analogRead(downPin) // read record joystick positionĭownVal = map(downVal, 0, 1023, 0, 179) // scale reading to servoĭownServo.write(downVal) //move servo to required positionĪny and all help/advice would be gratefully appreciated in this little DIY project of mine. ZoomVal = map(zoomVal, 0, 1023, 0, 179) // scale reading to servo ZoomVal = analogRead(zoomPin) // read zoom joystick position TiltServo.write(tiltVal) //move servo to required postion TiltVal = map(tiltVal, 0, 1023, 0, 179) // scale reading to servo TiltVal = analogRead(tiltPin) // read pan joystick position PanServo.write(panVal) //move servo to required position PanVal = map(panVal, 0, 1023, 0, 179) // scale reading to servo ![]() PanVal = analogRead(panPin) // read pan joystick position ZoomServo.attach(6) // use pin 6 PWM output for zoom servoĭownServo.attach(5) // use pin 5 PWM output for down servo TiltServo.attach(10) // use pin 10 PWM output for tilt servo PanServo.attach(9) // use pin 9 PWM output for pan servo Int downVal // Value read from the down axis Int zoomVal // Value read from the zoom axis Int panVal // Value read from the horizontal axis Int tiltVal // Value read from the vertical axis Int downPin = 3 // Analog input for the down axis Int zoomPin = 2 // Analog input for the zoom joystick axis Int tiltPin = 1 // Analog input for the joystick tiltl axis ![]() Int panPin = 0 // Analog input for the joystick pan axis Servo downServo // Create a servo obhect for record (down/up) servo ![]() Servo zoomServo // Create a servo object for zoom (left/right) servo Servo tiltServo // Create a servo object for the tilt (vertical) servo Servo panServo // Create a servo object for the pan (horizontal) servo #Pan tilt usb camera with iguard seriali dont have the button added to the code just yet nor the write to serial bc i am trying to get the main action resolved first.Ĥ servos ( other 2 are for zoom and other function) i have the generic code for the x and y axis and have that working fine, but i would like the camera to stay in the last position that i directed it to and then recenter with the system with the button press in the joystick. i built a pan/tilt camera system for my rc car. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |