LCD Display Programming Help!

  1. 6 weeks ago

    Hey guys, I'm having some difficulty programming an LCD display. We don't have any jumper clips too. Can anyone help me program the LCD to display potentiometer values and choose programs?

    I am assuming you mean the LCD for the edr cortex and you want to select autonomous and display potentiometer values in RobotC. To display a sensor value i would use the following
    clearLCDLine(0); //Clear line 1 (0) of the LCD clearLCDLine(1); //Clear line 2 (1) of the LCD int value = SensorValue[arm]; //stores sensor value of your potentiometer to value displayLCDString(0, 0,"Arm: "); //display a name of your potentiometer i.e. "Arm" displayNextLCDNumber(value); //Display the potentiometer value
    The code above displays a sensor value starting on the top line "0" and on the far left in box "0". You can also see all sensor values and variables in the debug tab of robotC, personaly this is what I would use unless you always need to see your potentiometer value.

    As for selecting programs this is a bit more complicated, there are many forum threads that can explain this better than I can but I will try. I attached a program I found here on the forum years ago and slowly changed it to what it is today. It is setup as an include file, meaning all of the code is in its own separate file and if placed in the same folder as your code can be included with the code #include "LCD Autonomous Selector.c" The file creates a task that can be called in your user control code that selects a program. I call the task when 2 buttons are pressed using following code if(vexRT[Btn8R]==1 && vexRT[Btn7L]==1) { waitUntil(vexRT[Btn8R]!=1 && vexRT[Btn7L]!=1); //wait for button unpress wait1Msec(20); startTask(Autonomous_Selector); //start task auton selector }
    This starts the task and allows you to select a program on the LCD. The result of the task stores the program you want to run as a integer with a value 1-4, to use this value my autonomous looks like this
    task autonomous() { clearLCDLine(0); // Clear line 1 (0) of the LCD clearLCDLine(1); // Clear line 2 (1) of the LCD //runs selected program switch(Program){ case 1: //Put first program here displayLCDCenteredString(0,"Autonomous 1"); //code break; case 2: //Put second program here displayLCDCenteredString(0,"Autonomous 2"); //code break; case 3: //Put third program here displayLCDCenteredString(0,"Autonomous 3"); //code break; case 4: //Put fourth program here displayLCDCenteredString(0,"Autonomous 4"); //code break; default://no auton selected //put code here break; } }
    I hope this helped a little, if you take a look in the attached files the code should be commented well enough to help explain what it does

  2. JDeuter

    Dec 10 Answer South Dakota 6844B

    I am assuming you mean the LCD for the edr cortex and you want to select autonomous and display potentiometer values in RobotC. To display a sensor value i would use the following
    clearLCDLine(0); //Clear line 1 (0) of the LCD clearLCDLine(1); //Clear line 2 (1) of the LCD int value = SensorValue[arm]; //stores sensor value of your potentiometer to value displayLCDString(0, 0,"Arm: "); //display a name of your potentiometer i.e. "Arm" displayNextLCDNumber(value); //Display the potentiometer value
    The code above displays a sensor value starting on the top line "0" and on the far left in box "0". You can also see all sensor values and variables in the debug tab of robotC, personaly this is what I would use unless you always need to see your potentiometer value.

    As for selecting programs this is a bit more complicated, there are many forum threads that can explain this better than I can but I will try. I attached a program I found here on the forum years ago and slowly changed it to what it is today. It is setup as an include file, meaning all of the code is in its own separate file and if placed in the same folder as your code can be included with the code #include "LCD Autonomous Selector.c" The file creates a task that can be called in your user control code that selects a program. I call the task when 2 buttons are pressed using following code if(vexRT[Btn8R]==1 && vexRT[Btn7L]==1) { waitUntil(vexRT[Btn8R]!=1 && vexRT[Btn7L]!=1); //wait for button unpress wait1Msec(20); startTask(Autonomous_Selector); //start task auton selector }
    This starts the task and allows you to select a program on the LCD. The result of the task stores the program you want to run as a integer with a value 1-4, to use this value my autonomous looks like this
    task autonomous() { clearLCDLine(0); // Clear line 1 (0) of the LCD clearLCDLine(1); // Clear line 2 (1) of the LCD //runs selected program switch(Program){ case 1: //Put first program here displayLCDCenteredString(0,"Autonomous 1"); //code break; case 2: //Put second program here displayLCDCenteredString(0,"Autonomous 2"); //code break; case 3: //Put third program here displayLCDCenteredString(0,"Autonomous 3"); //code break; case 4: //Put fourth program here displayLCDCenteredString(0,"Autonomous 4"); //code break; default://no auton selected //put code here break; } }
    I hope this helped a little, if you take a look in the attached files the code should be commented well enough to help explain what it does

  3. sabarrett328

    Dec 10 Grand Blanc, MI 46838C Major Trouble

    The girls used the code at Renegade Robotics for their menu this year. It seems to work well.

    The example here runs for autonomous selection, but they have made modifications to it so there is an LCD task that runs in driver control with multiple driver control info screens to aid in troubleshooting: one showing main and expander battery voltage, one that shows encoders, one that shows encoder and distance, and soon to have one that shows measured ultrasonic distances.

  4. 5 weeks ago

    Thank you all.

 

or Sign Up to reply!