> For the complete documentation index, see [llms.txt](https://docs.revrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.revrobotics.com/ftc-kickoff-concepts/home/programming-teleop-and-auto/programming-flywheel.md).

# Programming - Flywheel

The largest function within the program is that for the flywheel control. Let's break it down!

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2FitdvoN1gdM7RUPao31OR%2Fimage.png?alt=media&amp;token=30c5539a-91b6-4c53-9926-b634bbe73dcd" alt=""><figcaption><p>Full flywheel control function</p></figcaption></figure>

### Manual Flywheel Control

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2Frx1hUw0Iu0wMJcFcCwhq%2Fimage.png?alt=media&amp;token=d943fbbd-2669-4d61-857e-1b98b07fd4b7" alt=""><figcaption><p>Manual controls for the flywheel motor</p></figcaption></figure>

At the beginning of the `flywheelControls` function is the manual control for the flywheel. When triangle is held, the flywheel will spin up to the targetVelocity BUT the feeder will not activate.&#x20;

When square is held, the flywheel will spin in reverse near half power. This is intended to help with unsticking or repositioning game pieces if needed.

### Flywheel Auto Sequence

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2F0SgCDlIQpzH2WRuBUWfL%2Fimage.png?alt=media&amp;token=d91d759b-e765-4509-95da-9ab8ee22123b" alt=""><figcaption><p>The flywheel sequence for controlling the feeder and flywheel together</p></figcaption></figure>

Next is the sequence for the flywheel and feeder to activate together. When the flywheel spins up to the `targetVelocity` while left bumper is held, the feeder will wait until the current velocity is within range before also turning on. This is intended to prevent game pieces feeding too early for more consistent launches!

It's recommended to take some time testing this on your specific robot and making adjustments to this range based on your team's preferred launch location and robot set up.&#x20;

### Manual Feeder Control&#x20;

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2FchkQsM0selD8lIw0x9XX%2Fimage.png?alt=media&amp;token=8d820958-4dcf-4549-b82c-33e452d12cd1" alt=""><figcaption><p>Manual control for the feeder servo</p></figcaption></figure>

The feeder is controlled by a servo and intended to allow control of how the game pieces feed down into the flywheel.

Similar to the flywheel, there are manual controls for the servo feeder. When up on the dpad is pressed, the feed will move game pieces into the chute for the flywheel. When down on the dpad is pressed, the servo will spin in reverse pushing game pieces back into the intake. This is intended to help with unsticking or repositioning game pieces.

### Disabling Actuators

<figure><img src="https://268621232-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MHCAE012xNfg1h3SM9v%2Fuploads%2FnQOTH0tri0UVj31WekQI%2Fimage.png?alt=media&amp;token=5ee0d1b2-baa9-4843-8307-0528b4c721d4" alt=""><figcaption><p>The end of the flywheel function where the actuators turn off</p></figcaption></figure>

Lastly, if no button in the if/else statement is currently pressed then the flywheel motor and servo will be set to 0 power to be turned off.&#x20;
