We need to first initialize it by determining the resolution of the display and the size of the bit operation, whether we are doing a 4 bit operation or 8 bit operation, and we need to send a set of command bytes to the control register of the lcd And to send a command to the lcd, we need to first set pin rs to zero and then put the command code on the data pins. If were using a four bit operation, then pins d4 to d7, and then we need to send a high to low pulse, to pin enable and keep in mind. We have to wait 100 microseconds after each command to send data to lcd. We need to set, pin rs to 1 and then put the data on the data pins and then send the high to low pulse. To pin enable again we need to wait. 100 microseconds. This table shows you the lcd commands. The codes are in hexadecimal in this video well be programming. The lcd to operate in 4 bit operation were using data lines d4 and d7. So we need to send this hexacode to the command register of the lcd. The circuit shows the interfacing of the lcd with the digital ports of the uno. We have the data lines d4 to d7, our interface to pins pd4, to pd7 of port d. We have the enable line is connected to pin pb0 or port p, and we have the register select line connected to pin pb1 of port b a quick look at the assembly code.

We set port to d as output for data port b output for command. We put enable pin to zero, and then we apply delay in millisecond to wait for the lcd to power on next. We initialize the lcd. By calling this subroutine, then we send text message to the display by calling this subroutine and then we clear the lcd screen and then using a loop. We wait for approximately one second and then jump to label again, and the process is repeated continuously in subroutine lcd. Initialization we need to send the bytes 33 and 32 to the command register so that we initialize the lcd for 4 bit data and then we send the byte 28 so that we have two lines and five by seven matrix. And then we send the byte 0c. So that we have display on and cursor off, then we clear the lcd and then we initialize the lcd so that we have a shift to right. Cursor, keep in mind every time we send a command by to the lcd. We need to apply a delay of a few milliseconds subroutine command. Write will receive the command byte stored in register r16. Now to send this byte over the four bit data lines. We need to extract the heinoble and then send it over the data lines. So using the and operation we will mask the loanable and keep the high level. Then we can output this high novel to port d.

Then we set rs to zero and then we generate the short pulse for the enable, and then we apply a delay of approximately 100 microseconds. Next, we need to output the loanable part of the command byte stored in register r16. First, we need to copy it into register r27 and then using the swap op code. We swap the loanable with the high novel and then we mask the loanable and keep the heineble. And then we output the heineble to porti, and then we send the enable pulse and then wait for approximately 100 microseconds in a similar way through subroutine data right. We send the data byte stored in register r16 by first sending the high enable and then sending the low nibble in subroutine display message. We are sending character by character to the data register of the lcd by calling the datawrite subroutine and then we apply after each write. We apply a delay of approximately 0.25 seconds so routine delay. Microsecond uses a single loop to give us a delay of approximately 100 microseconds by calling the subroutine 90 times, which is delay short and delay short, has three operations with three clock cycles and subroutine delay. Millisecond uses a loop to give us a delay of approximately 20 milliseconds by calling the delay micro seconds of routine 40 times. Finally, subroutine delay seconds, which was explained in detail in my previous video uses a nested loop to give us a delay of 0.

25 seconds in a future video. The lcd will be programmed to display analog sensor values, input through analog to digital converter.

https://www.youtube.com/watch?v=U8OF9N5rULw