There are some programming logic errors that we can take a look at here. Let's walk through the program line by line:
Creates an integer variable called 'runTime' and sets its value to 1000. Everything looks good here.
Creates an integer variable called curRunTime and sets its value the current value of the T1 timer. The problem is; what is the value of the T1 timer at this point? Whatever value T1 holds, that's that will be assigned to curRunTime.
Clears the T1 timer. Note, however, that curRunTime has already been assigned the value that timer T1 had in the previous line of code; unless you specifically set the value of the timer T1 to curRunTime again, it will hold whatever value is already assigned to it.
Runs the loop while curRunTime is less than runTime (which is 1000). Since curRunTime is the original value of timer T1 (and is never assigned a new value), if the original value of timer T1 is less than 1000 the loop will run forever. Since the curRunTime variable is assigned timer T1's value early in the program (and the individual timers are reset each time the program is run), the value is most likely very small.
To solve this, you will need to first clear the timer value, then assign its value to curRunTime, and then make sure that you update curRunTime with timer T1's value inside of the while loop. We actually have a Video Trainer Curriculum video on this very topic you may want to look at (http://www.education.rec.ri.cmu.edu/pre ... index.html
, under the Sensing -> Line Tracking -> Line Tracking (Timer) video). There is even a simpler way to do this program, which will become clear to you once you watch the vidao (the video will show you exactly how to program it).
Check out our Blog
! And our Facebook page
Need help? Take a look at our Wiki
and our Forums.I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody