Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit 8561f46

Browse files
authored
Joystick Values README
1 parent 30c05c2 commit 8561f46

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

FRC_Project_02/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
# FRC Project 02 #
22
In this project, you are going to select a partner to be able to work with, and both of you will be creating algorithm that does the following:
3-
* When you initially run the robot code, the robot must initially move forward. But when you press a given button on the joystick, it must move backward. And when the button is pressed again, it should go back front, and so on and so forth.
3+
* You must create a drivetrain that moves forward or backward straight depending on the value of the ```leftJoySticky``` in the Joystick file. In order to drive straight, you are going to implement a program that can make the robot go straight by using encoder values.
4+
5+
## Using Joystick values ##
6+
In the previous lesson we learned that you can set a motor to speed from ```-1``` to ```1```. Fortunately, this is how the Joystick works to. Analog joysticks have values from ```-1``` to ```1```, and buttons have values of ```true``` or ```false```. So if you would like for the robot motors to move in the direction to the value of the ```leftJoySticky``` variable, the following code would work (Assuming you have created the Spark objects in the Motors file, and that you have created the ```joyStickObject``` object):
7+
```
8+
public void teleopPeriodic()
9+
{
10+
Motors.leftMotor.set(joyStickObject.leftJoySticky);
11+
Motors.rightMotor.set(-joyStickObject.leftJoySticky);
12+
}
13+
```

0 commit comments

Comments
 (0)