Well I got the rest of my code working per my post earlier but now I’m trying to add in a solenoid to be in one state while the button is pressed and return to the other when released. How would one do this using the logitech joystick and the trigger button? I’ve tried all the things online but always have one error or another
using java (should have mentioned that). I have been looking around on that site and am just kinda lost. Our original head programmer graduated last year and we swapped to vex so our new coder didn’t bother learning the FRC stuff.
This is what i have so far the button code at the bottom was my most recent try
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.MecanumDrive;
//import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
//import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.DoubleSolenoid;
import edu.wpi.first.wpilibj.Spark;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
/**
* This is a demo program showing how to use Mecanum control with the RobotDrive
* class.
*/
public class Robot extends TimedRobot {
private static final int kFrontLeftChannel = 2;
private static final int kRearLeftChannel = 3;
private static final int kFrontRightChannel = 1;
private static final int kRearRightChannel = 0;
private static final int kJoystickChannel = 0;
private MecanumDrive m_robotDrive;
private Joystick m_stick;
@Override
public void robotInit() {
var m_frontLeft = new Spark(0);
var m_rearLeft = new Spark(1);
var m_frontRight = new Spark(14);
var m_rearRight = new Spark(15);
// Invert the left side motors.
// You may need to change or remove this to match your robot.
m_frontLeft.setInverted(true);
m_rearLeft.setInverted(true);
var m_robotDrive = new MecanumDrive(m_frontLeft, m_rearLeft, m_frontRight, m_rearRight);
var m_stick = new Joystick(kJoystickChannel);
JoystickButton button1 = new JoystickButton(m_stick, 1);
}
//Override
public void teleopPeriodic() {
// Use the joystick X axis for lateral movement, Y axis for forward
// movement, and Z axis for rotation.
m_robotDrive.driveCartesian(m_stick.getX(), m_stick.getY(),
m_stick.getZ(), 0.0);
DoubleSolenoid launchersolenoid = new DoubleSolenoid(1, 2);
launchersolenoid.set(DoubleSolenoid.Value.kOff);
launchersolenoid.set(DoubleSolenoid.Value.kForward);
launchersolenoid.set(DoubleSolenoid.Value.kReverse);
}
if(joystick.getRawButton(1).pr
{
launchersolenoid.set(DoubleSolenoid.Value.kForward);
}
else
{
launchersolenoid.set(DoubleSolenoid.Value.kReverse);
}
}
as for the template I started with the meccanum example and change out motor controllers