Вы находитесь на странице: 1из 24

USING MIKROC

LCD INTERFACING
 MikroC offers an easy to use LCD library which
gives the user the ability to write bytes or strings
to an LCD using a 6-wire interface.
 Before we can use this library, we must define the
external dependencies to this library i.e the pin
configurations.
 The following functions are in the LCD library:
Lcd_Init
Lcd_Out
Lcd_Out_Cp
Lcd_Chr
Lcd_Chr_Cp
Lcd_Cmd
 This function is required to initialize the
microcontroller so that it can communicate
with the LCD module.
 Before we can use any other function in the
LCD library we must first execute the
Lcd_Init() function.
 A standard delay (e.g 100ms) is placed after
this function call to ensure that the module
has enough time to effectively initialize.
 This function is used to write a string to the
LCD.
 This function requires three arguments:
1. The row to start the string
2. The column to start the string
3. The string to be written
Example
Lcd_Out(1,5,”HELLO”);
 The Lcd_Out_Cp( ) function is also used to
write a string, however it will write the string
at the current position of the cursor.
 This function is used to write a character on
the LCD at a specific location.
 It requires the row, column, and the
character.
Example
Lcd_Chr(1,2,’P’);
 The Lcd_Chr_Cp() function works in the same
way, however it will display the character at
the current cursor position.
 This function is used to send commands to
the LCD.
KEYPAD INTERFACING
•The keypad is made up of rows and
columns
•When a key is pressed, continuity is
formed across the row and column
which the key is connected to.
•The microcontroller can therefore
check which row is continuous with
the column, thereby giving the
location of the pressed key.
 The Keypad library is used to communicate with a
4x4 keypad.
 However, with modifications it can be used for 4x3,
4x2, or 4x1 keypads.
 The functions in this library are:
Keypad_Init
Keypad_Key_Press
Keypad_Key_Click
 The keypad library uses a full 8-bit port for
connections.
 Before we can use this library we must specify which
port we want to use for the keypad, for example:
char keypadPort at PORTB
 This function initializes the microcontroller to
communicate with the keypad.
 A standard 100ms delay can be placed after
the initialization statement.
Example
Keypad_Init();
delay_ms(100);
 It is a function which returns a number depending on
which key has been pressed on the keypad. It uses a
default 4x4 keypad, where all rows are connected to the
upper 4 bits of the port and all columns to the lower 4
bits.


 It works in the same way as
Keypad_Key_Press(), however it only returns a
value after the pressed button has been
released.
 Select the keypad you want to copy (e.g the 4x4
default keypad)
 Right click the device and choose ‘decompose’

.
 Delete all the numbers and symbols in the
keypad

 And then add the desired numbers and


symbols using the 2D graphics text editor.
 Next, highlight the entire device and then
right click and choose ‘make device’.
 Give the device a name. (Do not change any
other setting). Then keep pressing next.
 Delete the text in the ‘Help File’ field and
press next.
 Choose ‘USERDVC’ as the library to save the
device to.
 Your device can now be used in your
simulations.
 Write a program using MikroC which will ask
the user for a 4 digit password (terminated by
the hash key), and if the password is correct a
green LED will turn on, and if incorrect then a
red LED will turn on.
Assume the password is 1234.
THANK YOU

Вам также может понравиться