LCD program selection?

My team is using RobotC and we can’t seem to get a program working that lets us choose the program in pre-auton and then works in autonomous in competition mode. Has anyone found one that uses RobotC and works in competition mode? We want to be able to select between 4 different options. Thankkkksss.

We didn’t “find” a program that works, we just made one. I’m not the programmer but it doesn’t seem too hard. We use PROS not RobotC so I won’t post the code here since it will be different anyways, instead take a look at this:
https://vexforum.com/t/how-to-program-lcd-display-robotc/24470/1

Lots of good older forum posts on this that you can look into.

jpearman code

@The Programmer I agree with Easton that writing your own program will make a lot more sense. I wrote mine and it made using it a lot easier. Nevertheless I think it is valuable to see what works and different ways of making something work. The biggest thing I would recommend is a failsafe button which would be able to exit the selection loop in driver control if something goes wrong. This is the code that I use:


int autoSelect = 0;
bool select = true;

void pre_auton() //pre autonomous task
{
	bStopTasksBetweenModes = true;

	//clear the gyro
	SensorType[gyro] = sensorNone;
	wait1Msec(20);
	//calibrate the gyro
	SensorType[gyro] = sensorGyro;
	wait1Msec(2000);
	SensorScale[gyro] = 138;

	clearLCDLine(0);
	clearLCDLine(1);
	bLCDBacklight = true;

	while(select == true)
	{
		if(nLCDButtons == 2 || vexRT[Btn8R] == true) //has failsafe button
		{
			select = false;
		}
		else if(nLCDButtons == 1)
		{
			if(autoSelect > 0)
			{
				autoSelect--;
				wait1Msec(100);
			}
			else
			{
				autoSelect = 3;
				wait1Msec(100);
			}
		}
		else if(nLCDButtons == 4)
		{
			if (autoSelect < 3)
			{
				autoSelect++;
				wait1Msec(100);
			}
			else
			{
				autoSelect = 0;
				wait1Msec(100);
			}
		}
		else
		{
		}

		if(autoSelect == 0)
		{
			clearLCDLine(0);
			clearLCDLine(1);
			displayLCDString(0, 0, "24 right"); //Shows autonomous
			displayLCDString(1, 0, "<"); //Shows press left button
			displayLCDString(1, 5, "Select"); //Shows select
			displayLCDString(1, 15, ">"); //Shows press right button
		}
		if(autoSelect == 1)
		{
			clearLCDLine(0);
			clearLCDLine(1);
			displayLCDString(0, 0, "24 left"); //Shows autonomous
			displayLCDString(1, 0, "<"); //Shows press left button
			displayLCDString(1, 5, "Select"); //Shows select
			displayLCDString(1, 15, ">"); //Shows press right button
		}
		if(autoSelect == 2)
		{
			clearLCDLine(0);
			clearLCDLine(1);
			displayLCDString(0, 0, "9 right"); //Shows autonomous
			displayLCDString(1, 0, "<"); //Shows press left button
			displayLCDString(1, 5, "Select"); //Shows select
			displayLCDString(1, 15, ">"); //Shows press right button
		}
		if(autoSelect == 3)
		{
			clearLCDLine(0);
			clearLCDLine(1);
			displayLCDString(0, 0, "9 left"); //Shows autonomous
			displayLCDString(1, 0, "<"); //Shows press left button
			displayLCDString(1, 5, "Select"); //Shows select
			displayLCDString(1, 15, ">"); //Shows press right button
		}
	}
}

We’ve been using this code for some years now, and love it (originally from @Ephemeral_Being here on the Forum). I wrote this article with step-by-step explanation of how to use it on your robot. I find it far superior in user interface than any other code I’ve seen:
https://renegaderobotics.org/our-favorite-lcd-menu-code/

Many thanks to @Ephemeral_Being – this code has been awesome!

I would look at the following channel.

https://www.youtube.com/channel/UCsOAxauOEMBqn6PM6n1UeIg

Martin has done a terrific job explaining how to use the LCD. I wish more students would be willing to share what they have learned.

If you would like me to send you the code we use just message me.

Hi Massey, could you please send me your code as we are looking at revising ours in case the cortex disconnects during auto. Sorry, I don’t know how to PM. joan_okai@notes.k12.hi.us Thanks. :slight_smile: joan

@josh_siegel We used your program as a base and added some variables to help it work during the autonomous period. Thx.

@The Programmer can you share how you changed it? Just curious?