Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

Exploring the Keypad

<^< Set up the Equipment | Course Index | Using String Variables >^>

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:

  1. Start a new flowchart using a 16F1937 device.
  2. Onto your flowchart put a keypad component and an LCD display. Connect the keypad to Port D and the display to Port B.
  3. Select 'Edit' and then click 'Variables...' from the menu (Edit > Variables...) and assign a new Byte variable called "key".
  4. 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.

<^< Set up the Equipment | Course index | Using String Variables >^>

Print - Search - Login

Page last modified on May 03, 2013, at 03:59 PM