New to Programming, trying to program buttons (xbox, etc)

Hi, So I am new to programming and I have been stuck on this one issue with coding: xbox controllers…

So basically here is an rundown on what I am trying to achieve:
I am trying to program an xbox controller to activate commands with the buttons and I am getting confused based off of “boolean” and “double”. Every time i set my command like this:

@Override
public void execute() {
// double y = RobotContainer.stickDriver.getY();
boolean spin = RobotContainer.oi.oController.getTopPressed();
RobotContainer.cellIntake.intakeSpinIn(spin);

It comes up with the error: The method intakeSpinIn(double) in the type CellIntake is not applicable for the arguments (boolean)Java(67108979)
And when i switch it to:
double spin = RobotContainer.oi.oController.getTopPressed():
It comes up with this error: Type mismatch: cannot convert from boolean to doubleJava(16777233)

I need help! I’m not sure if this amount of code will help explain this but let me know if you need some more extra detail.

Thanks so much!

I don’t know exactly what intakeSpin() does, but the error says that it needs a double to function not a button(boolean). If you want to put something on a button you need to do an if statement.

if(buttonPressed){
//do something when pressed
}

If you’re confused about the difference between a boolean and a double, I strongly recommend temporarily stepping away from robot code and working through some basic java tutorials.

5 Likes

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