I need a sample program for button = Autonomus

I am trying to program 5 different programs to launch off of 5 different buttons, how do i do it?

You need to wait for a button to be pressed.
Then you need to do something different for each button.

void auto1() { //Autonomous function 1
	motor[0] = 127;
	motor[1] = 127;
	wait1mSec(1000);
	motor[0] = 0;
	motor[1] = 0;
}

void auto2() {
	wait1mSec(1000);
}

int whichBtn = 0; //create variable called whichbtn; set it to 0
while (whichBtn==0) { //while it is zero...
	if (SensorValue[BTN1]) whichBtn = 1; //...check if a button is pressed
	if (SensorValue[BTN2]) whichBtn = 2; //...if a button is pressed...
	if (SensorValue[BTN3]) whichBtn = 3; //...then set whichBtn variable...
	if (SensorValue[BTN4]) whichBtn = 4; //...to match the button that...
	if (SensorValue[BTN5]) whichBtn = 5; //...was pressed. Changing...
} //...the whichBtn variable will automatically exit the loop.

switch(whichBtn) { //Now that the robot knows which one you want to run...
	case 1: auto1(); break; //... it has to run something different for each.
	case 2: auto2(); break;
	case 3: auto2(); break; //make the remaining point to other functions
	case 5: auto2(); break;
}

I think you would put this in the pre-auton.

Are you looking for easyc program or robotc?

I am looking for an easyC program please :slight_smile:

Is their any varibles that i need because by looking at the sample program up their the waits only say 1000 = 1 second

Is their anyway that i can get this in easyC, i have never really used RobotC and their are a few things in this program that i do not understand.

As in sensors, their are no sensors in EasyC, but their is just a drag and drop button command.

As nobody else has helped you, here is a simple example. Press one of five buttons after autonomous has started to select the function. Is that what you want?

As code

#include "Main.h"

void Autonomous ( unsigned long ulTime )
    {
    int waitForSwitch; 

    // This flasg is so we only run one autonomous
    waitForSwitch = 1 ;
    
    while ( waitForSwitch == 1 )
        {
        if ( GetDigitalInput(1) == 0 )
            {
            waitForSwitch = 0 ;
            // Silly autonomous - drive forwards 
            PrintToScreen ( "Auton 1\n" ) ;
            SetMotor ( 1 , 127 ) ;
            SetMotor ( 10 , 127 ) ;
            Wait ( 1000 ) ;
            SetMotor ( 1 , 0 ) ;
            SetMotor ( 10 , 0 ) ;
            }

        if ( GetDigitalInput(2) == 0 )
            {
            waitForSwitch = 0 ;
            // Another autonomous function 
            }

        if ( GetDigitalInput(3) == 0 )
            {
            waitForSwitch = 0 ;
            }

        if ( GetDigitalInput(4) == 0 )
            {
            waitForSwitch = 0 ;
            }
        
        if ( GetDigitalInput(5) == 0 )
            {
            waitForSwitch = 0 ;
            }
        
        Wait ( 20 ) ;
       }
}

As flowchart

https://vexforum.com/showthread.php?p=354647

What is Get digital input? Is it a variable or command?

It is a command. The variable would be unsigned char

Can you screen shot your variable page please?

There was only one variable “waitForSwitch”.

I entered GetDigitalInput(1) etc. directly into the dialog box for the if statement.