to simplify I have first explained separately LCD interfacing hex keypad interfacing ,motor interfacing with L293D
so Lets get Started !!!
Step 1: Materials Required
I assume u have basic knowledge of 8051 programming in assembly
Step 2: Interfacing DC Motor -L293D
As you can see in the circuit, three pins are needed for interfacing a DC motor (A, B, Enable). If you want to control speed enable pin is connetcted to the PWM pin of microcontroller . I have connected only one motor and used the enable pin to contol the speed of dc motor.
Step 3: Interfacing LCD
LCD consist of 16 pin
data pin D0 to D7
backlight pin LED and LED-
The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines.When RS is low (0), the data is to be treated as a command. When RS is high (1), the data being sent is considered as text data which should be displayed on the screen.
When R/W is low (0), the information on the data bus is being written to the LCD. When RW is high (1), the program is effectively reading from the LCD. Most of the times there is no need to read from the LCD so this line can directly be connected to Gnd thus saving one controller line.The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOW signal is required to latch the data. The LCD interprets and executes our command at the instant the EN line is brought low. If you never bring EN low, your instruction will never be executed.
Step 4: Interfacing HEX Keypad
The hex keypad has 8 communication lines namely R1, R2, R3, R4, C1, C2, C3 and C4. R1 to R4 represents the four rows and C1 to C4 represents the four columns. When a particular key is pressed the corresponding row and column to which the terminals of the key are connected gets shorted. For example if key 1 is pressed row R1 and column C1 gets shorted and so on. The program identifies which key is pressed by a method known as column scanning. In this method a particular row is kept low (other rows are kept high) and the columns are checked for low. If a particular column is found low then that means that the key connected between that column and the corresponding row (the row that is kept low) is been pressed. For example if row R1 is initially kept low and column C1 is found low during scanning, that means key 1 is pressed.
Step 5: Complete Code
ANL A,#0FH ; MASK HIGHER NIBBLE
now the number we get is converted into three digit number using convert motor
MOV R3,A ; SAVE NUMBER IN R3
MOV A,R1 ;
MOV R2,A ;Put counter in R2
MOV A,R3 ;PUT THE NUMBER BACK TO A
MUX: MOV B,#10
MUL AB ; MULTIPLY 10
DJNZ R2,MUX ;depending on position
when first number is entered it is multiplied by 100 then saved in R7 a counter in R1 is used to keep the track of digits place then the second number is multiplied by 10 and added to first number saved in R7 and the number unit place is added to get the PWM
after this execution the program jumps back to LCD to change the display ,and then PWM loop to rotate the motor with new PWM and the cycle continues
finally the complete code,hex file and proteus file is here