Servo errors

Every time I try to run my servo i receive a null pointer error any tips?

Please post the entire code and the entire stack trace (error).

Make sure you are initializing the servo object correctly.

sorry its late but here is a link to my code

Where within your code is your servo? I’ve checked your top level files (Robot.java, etc) and your subsystems. Please tell me you didn’t put direct code in one of your commands.

Solved here
https://www.chiefdelphi.com/t/servo-error/379549/5

i fixed the issue but it is in the lifter subsystem

I posted about this yesterday but I’m asking again every time I run my servo I get a null pointer error i have a link to my code https://github.com/Yellowmonk1/3719-Robot-Code but i dont know why the servo is not working

Where’s the servo being initialized and used in the code?

in the lifter it is being used to actuate a pawllock on our winch

The issue is in the Lifter constructor. You have a line like:

Servo servo1 = new Servo(0);

This hides the class variable servo1 leaving it null. Change it to:

servo1 = new Servo(0);

Hope that helps.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.