|
Introduction to Microcontroller Programming * Course Index * Introduction * About the Author * About this Course * Feedback * Course Navigation * Quick Course Navigation * How to use this Course * Acronyms Used and Course Conventions About PICmicro Chips * What is a PICmicro? * Microcontrollers * Digital versus Analogue * Inputs and Outputs * Memory * Programming * 16F1937 Architecture Clocking Your PICmicro Devices * Introduction * The Clock Circuit * Clock Settings * Clock Confusion E-Blocks * Introduction to E-blocks * Using E-blocks * E-blocks Boards Flowcode Step By Step * Introduction to Flowcode * Basic Flowcode Functions * Digital Outputs * Digital Inputs * Basic Loops ## Set up the Equipment ## Counting Sheep Badly ## Set up the Flowchart ## Create the Variables ## Set up the Calculation ## Loop Properties ## Set up the Input ## Set up the Output ## Adding the LED array ## Adding the Switches ## Simulation ## The Solution - Adding a Delay * The LCD Display * Binary Numbers * Decisions * Goto (Connection Point) * 7-Segment Displays * Software Macro * Strings and Memory * A Simple Hi-Fi PICmicro Projects * Introduction to PICmicro Projects * Construction Methods * Choosing a Power Source * Adding Inputs * Input Conditioning * Adding Outputs * Adding Drivers Labs * Introduction and Lesson Plan * 1. Output * 2. Delay * 3. Connection Point * 4. Calculations * 5. Loop * 6. Input * 7. Decision * 8. LCD * 9. Keypad * 10. Analogue + EEPROM * 11. Software Macro * 12. External Interrupt * 13. Timer Interrupt |
(:Summary:Contains the 'action' links (like Browse, Edit, History, etc.), placed at the top of the page, see site page actions:) (:comment This page can be somewhat complex to figure out the first time you see it. Its contents are documented at PmWiki.SitePageActions if you need help. :) * Print (:comment (:if group Site,SiteAdmin,Cookbook,Profiles,PmWiki*:) (:comment delete if and ifend to enable backlinks:) * %item rel=nofollow class=backlinks accesskey='$[ak_backlinks]'% [[{*$Name}?action=search&q=link={*$FullName} | $[Backlinks] ]] (:ifend:) :) * Login The Solution: Adding a Delay<^< Simulation | Course Index | The LCD Display >^>(:nl:) # 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: ![]() # Double-click on the Delay icon to open the Properties dialogue box. ![]() # 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. # 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. # 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. (:nl:)(:table style="clear:both":)
| |
(:Summary: Website page footer:)
Print - (:comment (:if group Site,SiteAdmin,Cookbook,Profiles,PmWiki*:) (:comment delete if and ifend to enable backlinks:) %item rel=nofollow class=backlinks accesskey='$[ak_backlinks]'% [[{*$Name}?action=search&q=link={*$FullName} | $[Backlinks] ]] (:ifend:) :) Search - Login
Page last modified on August 14, 2013, at 03:45 PM