Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

The Solution: Adding a Delay

<^< Simulation | Course Index | The LCD Display >^>

  1. The problem is that the program runs too fast! Before we have time to release the switch, the program has run through several times, adding one to the total each time. We need to slow things down by adding a delay. Move the cursor over the 'Delay' icon. Drag it onto the main work area and drop it between the Calculation icon and the Output icon.
The flowchart should now looks like this:
  1. Double-click on the Delay icon to open the Properties dialogue box.
  1. Change the value in the 'Delay value or variable' box to 200, and then click on the OK button. This causes a 200 millisecond (0.2 second) delay when the Delay icon is activated. In other words, the system just sits there and does nothing for 0.2 seconds.
  2. Now run the simulation once again. Providing you don't keep the switch pressed for too long, you should find that the LED array shows an increase of 1 each time you press the switch.
  3. The program now works satisfactorily, providing the sheep rush through the light beam in less than 0.2 seconds. The delay could be increased to allow for slower sheep!

One of the problems with this program is that it shows the total number of sheep in binary format. That is interesting, but not that useful. In the next section you will learn how you can use the LCD display to show numbers in a more human friendly decimal format.

<^< Simulation | Course index | The LCD Display >^>

Print - Search - Login

Page last modified on August 14, 2013, at 03:45 PM