Can someone check our code

We wrote this code that runs successfully without having any errors, and it says on the DS that communication and robot code are all good. However, our robot does not move at all when we deploy the code. Can someone look through our code to see if our issue is with the code itself? Thanks. We just want our robot to move in literally any direction. :o

package org.usfirst.frc.team6898.robot;

import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.Joystick;

public class Robot extends IterativeRobot {
	Spark driveLeftFront = new Spark(2);
	Spark driveLeftRear = new Spark(1);
	Spark driveRightFront = new Spark(0);
	Spark driveRightRear = new Spark(3);
	Joystick xbox = new Joystick(0);
	
	
	public void robotInit() {
		
	}
	
	public void operatorControl() {
		
	}
	
	public void autonomousInit() {
	}
	public void autonomousPeriodic() {
		
	}
	
	public void teleopInit() {
		
	}
	
	public void teleopPeriodic() {
		double leftStickY = xbox.getRawAxis(1);
		double rightStickY = xbox.getRawAxis(5) * -1; 
		
		driveLeftFront.set(leftStickY);
		driveLeftRear.set(leftStickY);
		driveRightFront.set(rightStickY);
		driveRightRear.set(rightStickY);

		
	}
	
	public void testPeriodic() {
		
		
	}
}
	
	

I think the best way is to use The robot drive Class

check this :https://wpilib.screenstepslive.com/s/currentCS/m/java/l/599700-getting-your-robot-to-drive-with-the-robotdrive-class

But for your code : Maybe you don’t get the right Input from your Joystick

I echo Jude99999’s comments. WPILib provides a nice wrapper around motor controllers so you can easily bind joysticks to arcade/tank drives. That being said, your code looks like it should still move the bot.

If I were you, I’d consider trying some of the following troubleshooting stuff:

  • Does the Driver Station show that it’s registering your XBox controller? Is the controller you’re using the one the DS has listed as #1?
  • Are the PWM ports you’re using in code the ones you’re really wired to?
  • Are you reading expected voltages across your motor controller’s input and output wires?
  • Are your motors turning against each other? That is, is one CIM on one side turning counterclockwise, and the other cim on the same side turning clockwise?

I think we originally tried something like that, but it didn’t move our robot either. We thought changing it to do something like this would at least make something move, but still nothing is moving.

Yep, robot code, joysticks, and robot communication are all green and everything’s connected properly.

The PWM ports should be correct, and we’re reading expected voltages after testing. If the motors are turning against each other, would that cause the robot not to move? (Although we can still turn the wheels while the program’s running, if that makes a difference).

Thank you!

Define “expected voltages”… what are the output voltages on the controllers while using the program?

To confirm, you are using Spark motor controllers, right?

What are the status LED’s on the motor controllers doing during your test? Look at it when the robot is disabled, when it’s enabled, and when you’re moving the joysticks.

You can see what the LED’s should be doing at any time on page 14 of the user manual.

If the status LED’s are doing what they should be doing as you switch between drive modes and move the joystick, then you know the problem isn’t the code - it’s the wiring! And if the status LED’s aren’t doing what they should be doing… well, it could still be the wiring, or it could be the code, depending on what they’re actually doing.

A little over 12 I think, last time we checked. And yes, we’re using SPARKs.

The LED’s on the SPARK are flashing blue no matter what we do (robot enabled, disabled, moving joysticks, etc.). According to the user manual, that means “no signal brake”. Basically we get no indication that anything’s happening besides the green indicators for robot connection, joysticks, and robot communication on the driver station. We think there might be something wrong with the installation of various software on our driver station laptop but have no idea, since again there’s no indication of anything happening or going wrong.

Can you upload a photo of your electronics board and sparks? I bet you’ve got wires backward.

Here’s a couple pictures: https://imgur.com/a/f5okU
Please excuse our messy wiring :]

The PWM cables are connected to the Sparks backwards. See figure 2-2 in the user manual for the correct wiring. The black wire (ground) should be plugged in next to the B.

Yep, that fixed it. Thank you everyone!