Announcement

Collapse
No announcement yet.

Making a timer ROBOTC

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Making a timer ROBOTC

    So in my driver control program I have the robot showing the program run time and, I was hoping, below the program run time to show the match time that was started by the press of a button. Does anybody know how to do that?

  • #2
    Here is one potential solution.

    Code:
    // Demonstrate how to use user timer1
    task main()
    {
        bool    isStarted = false;
        
        while(1)
            {
            // Only detect start button once
            if( vexRT[ BtnFUp ] == 1 && !isStarted ) {
                // Start match timer
                clearTimer(T1);
                isStarted = true;
            }
        
            // Display user timer
            if( isStarted ) {
                displayTextLine( 1, " Run %7.2f", time1[T1] / 1000.0 );
            }
            else {
                displayTextLine( 1, " Waiting ...");
            }
    
            // Other driver control code here..
            
            wait1Msec(25);
            }
    }

    Comment


    • #3
      Hi nathanpitts2002,

      Couple of suggestions.

      1. You won't be able to see the LCD screen unless you are right over it. Instead use an LED sensor and change the color to report status. For instance, Green at the start of the match, yellow to switch drivers, ... Red for the final 10 seconds.

      2. You may want to put your timer code in a separate thread with sleep commands between color changes.

      Comment

      Working...
      X