![]() |
How to Program a Servo
Okay I am not sure how to program the servo, I have a servo plugged into the digital sidecar on PWM #3, and I am not sure how to program it moving so this is the code that we have, so could you tell us our problem?
Code:
#include "WPILib.h" |
Re: How to Program a Servo
I think your major problem is that you haven't read any of the documentation on C++ coding: http://first.wpi.edu/Images/CMS/First/FRC1718Docs.zip There's a nice packet of information there. Here's how to fix your program:
Code:
void OperationControl(void)Also, make sure you have a jumper set on the sidecar next to the pwm output for the servo. |
Re: How to Program a Servo
Quote:
|
Re: How to Program a Servo
Quote:
servo.Set() accepts a range from -1 to 1 for min to max values of the servo - this is here so you can just directly accept another float value from something else (like a joystick) and just set it directly. servo.SetAngle() accepts an angle that you wish to set your servo at. Try using this with your 170 angle and see if that works. |
Re: How to Program a Servo
Quote:
Quote:
|
Re: How to Program a Servo
Quote:
If you need to scale (-1, 1) to (0, 1) you can use prevVal = joystick(1)->Get(); //-1 to 1 value ScaledVal = (prevVal + 1)/2; //Scaled to 0 to 1 |
| All times are GMT -5. The time now is 02:57. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi