![]() |
Trouble with servo
Hi there,
I have been searching everywhere to find a way to program a servo using Java. While I have found many great sources, none have been helpful. I am using NetBeans as the IDE and the program is iterative. what I am trying to do is creat a command that will cause the servo to rotate from one of it's maximums to the other in order to release a spring loaded "stinger". I am new to Iterative programming and am wondering also if I need to create a subsystem before I can create the command. I do however have the button mapping worked out, and I also know where and how to hook the servo up to the sidecar. It is only code that I need in order to make the servo move. I don't have a clue where to begin as this is my first time working with servo's in software, and any help at all would be greatly appreciated. Thanks to all, Andrew Brown Team 3310 |
Re: Trouble with servo
Operating a servo from within the iterative template is as simple as just creating and object for the servo(and whatever controls it) and setting it's values.
Here's a sample for what you might be looking to do: Code:
Servo stinger = new Servo(/*Servo port here*/); |
Re: Trouble with servo
Thank you,
This has helped, however I do not understand where you are getting the set(int) method, and apparently neither does the code. The error is that It cannot find the symbol. Also I am getting this error if you have any clues as to why, that would be helpful method whenPressed in class edu.wpi.first.wpilibj.buttons.Button cannot be applied to given types; required: edu.wpi.first.wpilibj.command.Command found: edu.rhhs.frc.commands.ServoOpen reason: actual argument edu.rhhs.frc.commands.ServoOpen cannot be converted to edu.wpi.first.wpilibj.command.Command by method invocation conversion ---- Thanks |
Re: Trouble with servo
the Servo.set method takes a double input, so you could try to make it 1.0 and 0.0. Or you could use the setAngle with the inputs 0.0 and 180.0.
Are you sure you're using the iterative structure? It seems like you are trying to use the CommandBased structure |
| All times are GMT -5. The time now is 10:12. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi