Adjusting speeds for flywheel and drivetrain during a match

I want to be able to adjust the speed of the drivetrain and the fly wheel during a match. Does the code look right? Also we have an x-drive base.

Take a look at using functions. A best practice in programming is DRY - don’t repeat yourself. If you find that you are copying / pasting the same code, stop and decide if you should use a function instead.

Using functions (My Blocks) allow you to place your velocity settings in one spot. If later you decide that the A button should be 35% instead of 25%, you only need to change one value.


Once I add that do you think the code will work.

does this look better

More compact, yes. But unless I read it wrong, it won’t work like you want.

You’ve got a forever loop that sets wheel velocities… but in the same loop you are setting them to 25/50/75/100 by using buttons. These two things are going to fight for control of wheel velocities.

Also, I’d put the spin wheel forward command BEFORE the forever loop. They only need to run once.

Free tip: have the brain screen turn bright green when the flywheel rpm reaches the desired value… then you know it’s ok to fire a disc.

So take it our of the forever sequence and it should work

This link might be a better solution.

You could create a ratio variable and multiply the driver velocities. Then set the variable (.25, .50, .75, 1) like you have with the if statements.

Probably not. Are speed button for wheels or flywheel?