ROBOTC.net forums
http://robotc.net/forums/

timers not sure I understand them also LED on and off
http://robotc.net/forums/viewtopic.php?f=11&t=3243
Page 1 of 1

Author:  TomH [ Wed Apr 27, 2011 10:17 pm ]
Post subject:  timers not sure I understand them also LED on and off

Do I need to clear the timer when I wait for an example

motor[port4] = closegripper; //close gripper around can
ClearTimer(T4); //clear timer
wait1Msec(80); //

So do I clear the timer each time and if so how does it know which timer. I am a little confused or is the "wait1Msec" different than a timer

I think my problem really is a timer issue I just am not sure how to set them up

Also can any one tell me how to turn on and off a LED

Author:  MHTS [ Thu Apr 28, 2011 1:02 am ]
Post subject:  Re: timers not sure I understand them also LED on and off

Take out the ClearTimer line and you will be fine. The wait1Msec(80) statement will do the right thing to "wait for 80 msec".

Author:  magicode [ Thu Apr 28, 2011 5:51 am ]
Post subject:  Re: timers not sure I understand them also LED on and off

There is a difference between timers and wait1MSec(). When you implement Wait1MSec, your program(or at least the task that you are in) goes to sleep for the amount of milliseconds specified. So in effect, your program pauses for that much time. Timers will not cause your program to pause, but will be counting in the background. They are used when you need to know how long it's been, but don't want to interrupt your program (they can also be used to stop your program from entering another task, but don't worry about that unless you need to). You can have 4 timers: T1, T2, T3, and T4. As soon as you call ClearTimer(T1), the timer T1 resets and starts counting from zero. You can access the value of a timer by saying time1[T1].

as for the LED, you need to configure the sensor port which the LED is in on the microcontroller as a digital output. You can do this in the motors and sensors setup. To turn it on, you write SensorValue[LED1] = 0, and use whatever name you named the port instead of LED1. To turn it off, use SensorValue[LED1] = 1.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/