Programming with Easy C Autonomous

I already did a search on this and it brought up tons of autonomous threads, to many to read. Yes, I have one out there also. I just need a quick question. I use Easy C and I read on my previous post about this that you can use different buttons to different actions and it is considered autonomous. How do I make up a new autonomous program and assign it to another button? (Like on the 7 or 8 channel) What I want to do is have a button we can press and it is offensive mode, another button for defensive, ect…

Thanks in advance,
eloveless

FYI ]

If I had been following more of your posts, I would know the answer to the following, but since I don’t, I need to make a guess, and request in the future for you to, please be as thorough as possible in describing your Robot and Environment…

== Programming ==

[LIST=1]
*]Vex Microcontroller ( e.g. Vex PIC ( AKA v0.5 ), Vex Cortex ( AKA Coretx-M3 ), VexPro ( AKA ARM9 ) )
*]Vex Controller (e.g. 75Mh Transmitter & Receiver ( AKA Crystal Controller ),75Mh Transmitter with VEXnet Transceivers ( AKA VEXnet Upgrade ), VEXnet Joystick )
*]Peripherals on the Microcontroller, especially the ones you are requesting help with, but also list the others, since there might be conflicts or resource limitations.
*] Programming Tool-chain and Version ( e.g. EasyC 1.x, EasyC 2.x, EasyC Pro (v3.x), EasyC 4.x, RobotC v1.x, RobotC v2.x, RobotC v3.x, MPLAB Version, SDCC Version )
[/LIST]

/FYI ]

The really short answer is, I don’t think it can be done…

I am Guessing that the 7 or 8 channel is some of the Buttons on the VEXnet controller, and you are using the Vex Cortex Microcontroller, which means EasyC v4.x…

To the best of my knowledge, the VEXnet Controller is ignored until the Vex Microcontroller leaves Autonomous Mode… You need to test this out to be sure…

Now, using a Vex Jumper on an I/O Port, and reading it like a Digital Switch would work in Autonomous Mode.
You would Pre-Set the Jumper, before the Match Begins and When Autonomous Mode begins, the Jumper would indicate the mode to executed…

This would be independent of the Vex Controller used as well as the Programming Tool chain… Also, IF the VEXnet Controller is Read during the Autonomous Mode, the Logic would be mostly the same, but instead of an I/O Port, you would read a Controller Button, since the Digital I/O Port and the Button both return a True or a False value.

There are buttons, and then again there are buttons :slight_smile:

I assume you are referring to this previous thread and in particular this post.

In this case the discussion was about different physical buttons on the robot, meaning bumper switches and limit switches. You could choose between hitting different “buttons” to trigger different actions.

As Mark correctly states, you cannot use the “buttons” on the VEXnet joystick until the driver control period.

Bumper switches, limit switches (and jumpers) are detected as digital inputs to the cortex. In EasyC you read them by using the GetDigitalInput function.

For example, this would read a jumper in digital port 1 to choose between two different actions.

(This code assumes a switch pressed returns 0, may have that reversed and don’t have EasyC running right now)

#include "Main.h"

#define PRESSED     0
#define NOT_PRESSED 1

void Autonomous ( unsigned long ulTime )
{
      if ( GetDigitalInput( 1 ) == PRESSED )
          {
           // Do something here 
          }
      else
          {
           // Do something else 
          }
}

The following would wait for one of two switches connected to digital ports 1 & 2 to be hit before proceeding and then choose one of two actions.

#include "Main.h"

#define PRESSED     0
#define NOT_PRESSED 1

void Autonomous ( unsigned long ulTime )
{
      int Switch_1 = NOT_PRESSED; 
      int Switch_2 = NOT_PRESSED; 

      // Wait for switch to be pressed 
      while ( (Switch_1 == NOT_PRESSED) && (Switch_2 == NOT_PRESSED) )
          {
           Switch_1 = GetDigitalInput ( 1 ) ;
           Switch_2 = GetDigitalInput ( 2 ) ;
           Wait ( 50 ) ;
          }

      if ( Switch_1 == PRESSED )
          {
           // Do something 
          }

      if ( Switch_2 == PRESSED )
          {
           // Do something else 
          }
}

Hope this helps.