Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

A More Useful Counter

<^< Other LCD Functions | Course Index | Binary Numbers >^>

  1. Expand your program by dragging a Loop icon below the 'PrintString' Component Macro.
  2. Change the text in the 'PrintString' Component Macro to "Hundredths:" (with quotation marks).
  3. Drag a Calculation icon into the Loop. Set up a variable called "Count" as an 'Int' type. Double-click on the Calculation icon. In the 'Calculations:' text box type "Count = Count + 1". This will add 1 to the value of variable count every time the icon is executed.
  4. Next drag another Component Macro into the Loop. Double-click the Component Macro and find 'Cursor' under the 'LCD' macros and enter '0,1' in the parameters. This will position the cursor on the first character of the second line.
  5. Next drag another Component Macro onto the workspace and do the same but select 'PrintNumber' instead and enter "Count" as the parameters.
  6. Next drag a Delay icon into the program and set the delay to 10ms or a hundredth of a second.
  7. Go over the program and click on each icon entering comments on what each icon does. This seems like a lot of effort, but if you can discipline yourself to entering comments you will save time in the long run as your programs will be easier to read.
  8. Run the program. You have now made a counter that will count (approximately) the time elapsed in hundredths of seconds.

<^< Other LCD Functions | Course index | Binary Numbers >^>

Print - Search - Login

Page last modified on May 07, 2013, at 01:36 PM