Manual boost buttons for flywheel ( RobotC help)

Boost and slow down buttons (RobotC programming beginner )

I’m new to programming in C language and I need some help with our flywheel code.

So we have 6 motors on one flywheel and we want manual control of the speed of the flywheel.

So how do I set my motors to a certain speed(power value) during the start of the match and then have a button on the remote which boosts the speed by 5 each time the button is pressed and another button which decreases the speed by 5 during driving period?
We want the boost buttons to keep the flywheel spinning at the same speed and if power drops, we can manually add a little boost to it by pressing a button.

here is what the code looks like:

#pragma config(Motor,  port1,           BtmIntake,     tmotorVex393_HBridge, openLoop)
#pragma config(Motor,  port2,           LeftDrive,     tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor,  port3,           LBtmL,         tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           LMidL,         tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port5,           RMidL,         tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           RBtmL,         tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port7,           RUpL,          tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port8,           LUpL,          tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port9,           RightDrive,    tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor,  port10,          UpIntake,      tmotorVex393_HBridge, openLoop)

void flywheel (int speed)
{
	speed=0;
	motor[LBtmL]= speed;
	motor[LMidL]= speed;
	motor[LUpL] = speed;
	motor[RBtmL]= speed;
	motor[RUpL] = speed;
	motor[RUpL] = speed;
}



task main ()
{
	flywheel (60);
if(vexRT[Btn7U] == 1)
{
	{
		flywheel (+5);
	}
}


if(vexRT[Btn7R] == 1)
{
	{
		flywheel (-5);
	}
}

}

Here is what the flywheel code that we used previously looked like, it should work if you take the concept:

#pragma config(Sensor, dgtl4, LimitTop, sensorDigitalIn)
#pragma config(Motor, port1, FL, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, LaunchRight, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, LaunchLeft, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, UpLeft, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, UpRight, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, IntakeRight, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, IntakeLeft, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, FR, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port9, BL, tmotorVex393_MC29, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//

float lleft = 0;
float lright = 0;

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)

#include “Vex_Competition_Includes.c” //Main competition background code…do not modify!
string mainBattery, backupBattery;

void pre_auton()
{

bStopTasksBetweenModes = true;

}

task Launcher()
{
if(vexRT(Btn8D))
{
lleft = 0;
lright = 0;
}
//full
if(vexRT(Btn7U))
{
lleft = 65;
lright = 65;
}
//3/4
if(vexRT(Btn7R))
{
lleft += 3;
lright += 3;
}
//low
if(vexRT(Btn7D))
{
lleft = 50;
lright = 50;
}
//mid
if(vexRT(Btn7L))
{
lleft -= 3;
lright -= 3;
}
if(vexRT(Btn8R))
{
lleft += 1.5;
lright += 1.5;
}
//mid
if(vexRT(Btn8L))
{
lleft -= 1.5;
lright -= 1.5;
}
if(vexRT(Btn8U))
{
lleft = 40;
lright = 40;
}

motor[LaunchLeft] = lleft;
motor[LaunchRight] = lright;

}

task usercontrol()
{

while (true)
{

	startTask(Launcher);


}

}

A super concise way to do it in psudeocode:
Int speed=0;
While (1){
Speed+=vexRT[7u];
Speed-=vexRT[7r];
Motor[launcher]=speed;
Wait1msec(20);
}

This is the code that we use to fix the exact problem you are having. The flywheel speed can start off as whatever you want them to; however the “additionalspeed” has to equal 0. Once you hit the button that makes the speed increase, you must hit the decrease button because once you try stopping the flywheel, it will still run. I hope this helps, and if you have any questions, don’t be afraid to ask.
This Helps.png

That was exactly what I was looking for! Thanks to everyone who contributed… love this forum :slight_smile: