Recent Changes - Search:
<^< Set up the Equipment | Course index | Using String Variables >^>

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 * The LCD Display * Binary Numbers * Decisions * Goto (Connection Point) * 7-Segment Displays * Software Macro * Strings and Memory ## Introduction ## Set up the Equipment ##

Exploring the Keypad ## Using String Variables ## ASCII ## Seeing ASCII ## Getting a Phone Number ## You try it ## EEPROM * 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

Exploring the Keypad

<^< Set up the Equipment | Course Index | Using String Variables >^>(:nl:)

In this section we will take a look at how the keypad works. Using the keypad to enter only a single digit is easy enough, but using it to enter numbers larger than 10 introduces some complexities. First the basics though:

# Start a new flowchart using a 16F1937 device. # Onto your flowchart put a keypad component and an LCD display. Connect the keypad to Port D and the display to Port B. # Select 'Edit' and then click 'Variables...' from the menu (Edit > Variables...) and assign a new Byte variable called "key". # Assemble the following flowchart:

->In top to bottom icon order this is explained as follows: start the LCD display, an endless loop, set the LCD 'Cursor' to '0,0' (top left), call the 'GetKeypadNumber' macro and put the result in the variable 'key'. Lastly display variable 'key' on the LCD using the LCD 'PrintNumber' macro.

If you run the program you will see that to start with the LCD displays the number 255. This is what the keypad returns when there is no button pressed. When you press a key the display will print the number of the key pressed. However you will notice that it does not erase all of the old number. To do this enter a new LCD Component macro with the function 'Clear' after the 'Cursor 0,0' macro and you will see only the number pressed.

On the keypad there are the numbers 0 to 9 as well as # and * keys. These are allocated the numbers 10 and 11. You can use the # and * keys as control characters to allow humans to indicate that the number is complete: a bit like the 'Enter' key on your computer keyboard.

To understand how you can use the keypad to enter larger numbers you need to now learn a few new concepts: what ASCII is, and how strings work. (: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 May 03, 2013, at 03:59 PM