diff --git a/Timers-in-FTC-Blocks.md b/Timers-in-FTC-Blocks.md index dab5c5f..1c47787 100644 --- a/Timers-in-FTC-Blocks.md +++ b/Timers-in-FTC-Blocks.md @@ -31,12 +31,20 @@ In general you will create your own timer, then use pre-made commands or meth ## Create a Timer -The first step is to create a new timer object. Here we call the new timer object "myTimer". You could think of it as "My New Stopwatch" (although Blocks timers don't actually stop). +The first step is to create a new Variable, called "myTimer" (or any other name that suits its purpose in your OpMode). -> **Programming note:** In Java, an Object is an instance or example of a Class. FTC Blocks provides a class called ElapsedTime. A class can contain variables and methods (commands). Your new timer is an instance of that Java class, inheriting its characteristics. +

[[/images/Timers-in-FTC-Blocks/0115-create-variable.png|]]

+ +But "myTimer" will not be an ordinary variable that stores a number, or text, or Boolean value. + +From the Variables menu, and from the ElapsedTime menu, create this Blocks command:

[[/images/Timers-in-FTC-Blocks/0120-set-myTimer.png|]]

+Now "myTimer" is a timer object, which you can think of as "My New Stopwatch" (although Blocks timers don't actually stop). + +> **Programming note:** In Java, an Object is an instance or example of a Class. FTC Blocks provides a class called ElapsedTime. A class can contain variables and methods (commands). Your new timer is an instance of that Java class, inheriting its characteristics. + This is not the usual Blocks "Set" command. Instead of assigning a number to a variable, this Block creates or instantiates a new object called myTimer. The Java keyword new causes myTimer to be created as an instance of the class ElapsedTime. The default unit of reporting time is Seconds, for a timer created with the simple Block shown above. An option for Milliseconds is discussed far below. @@ -288,3 +296,8 @@ This tutorial described basic use of Timers in Blocks programming. Timers also
Questions, comments and corrections to: westsiderobotics@verizon.net

+ + \ No newline at end of file