1
00:00:03,790 --> 00:00:09,100
So let's declare let's avoid function call and delay my call.

2
00:00:10,750 --> 00:00:15,340
And it takes one argument which is a tight end.

3
00:00:15,420 --> 00:00:22,180
And in this function what we're going to do is we're going to use a nested full loop to create a forced

4
00:00:22,180 --> 00:00:24,790
DeLay and nested for loop.

5
00:00:24,800 --> 00:00:31,140
This feels like this end with two local variables and I and J.

6
00:00:31,600 --> 00:00:42,850
And what we're going to do is four by four equals zero and I by less than and remember and is the name

7
00:00:42,850 --> 00:00:52,660
of the document that the function accepts plus plus and then inside I inside I would call that a for

8
00:00:52,660 --> 00:00:59,580
loop inside this first for loop we have k equals zero J less than three

9
00:01:02,380 --> 00:01:07,050
J plus plus and then this does nothing.

10
00:01:07,080 --> 00:01:10,800
This is just to waste time basically.

11
00:01:11,070 --> 00:01:15,340
So do not worry about where the stumble came from.

12
00:01:15,390 --> 00:01:22,990
There is a calculation for it based on the frequency of our microcontroller which is 16 megahertz.

13
00:01:23,040 --> 00:01:26,700
I wouldn't go into the details of how we derive this number of course.

14
00:01:26,700 --> 00:01:30,450
This is not the right way of performing delays.

15
00:01:30,450 --> 00:01:32,100
We would use the right when later.

16
00:01:32,310 --> 00:01:34,360
So do not worry about this number.

17
00:01:34,680 --> 00:01:38,590
So we'll need to delay functions as we said while we are here.

18
00:01:38,610 --> 00:01:40,620
How will we create the other delay function.

19
00:01:40,620 --> 00:01:44,490
This one is going to give us delay in millisecond units.

20
00:01:44,830 --> 00:01:53,910
So I'm going to declare us forward delay merely and it also takes one procurement and the same way we

21
00:01:53,910 --> 00:01:56,960
use and nested for loop.

22
00:01:56,970 --> 00:01:58,150
And then J.

23
00:01:58,380 --> 00:02:08,910
And without for I call 0 then I less than an then R plus plus

24
00:02:12,760 --> 00:02:15,790
Brandis and call on her plus plus.

25
00:02:15,810 --> 00:02:19,720
And then we have that in the loop which is J.

26
00:02:19,980 --> 00:02:23,580
Because 0 overhead J is done.

27
00:02:23,600 --> 00:02:25,070
You want a zero.

28
00:02:25,080 --> 00:02:27,470
Do not worry about this number as well.

29
00:02:27,580 --> 00:02:27,810
J.

30
00:02:27,840 --> 00:02:29,290
Plus plus.

31
00:02:29,490 --> 00:02:32,130
And it does nothing.

32
00:02:32,130 --> 00:02:36,740
So this is what these are not delay functions.

33
00:02:36,750 --> 00:02:38,260
They are forced to place.

34
00:02:39,270 --> 00:02:39,720
Yes sir.

35
00:02:39,740 --> 00:02:42,910
Let's go back here now we have a delay.

36
00:02:42,900 --> 00:02:46,790
So in order to enable it we delay here.

37
00:02:46,950 --> 00:02:54,080
The reason why we have this is because we have not added to function prototype of the Hubble we add

38
00:02:54,080 --> 00:02:55,930
a prototype.

39
00:02:56,130 --> 00:02:57,630
I really do not like this.

40
00:02:57,660 --> 00:03:00,600
Red lines say to stop it.

41
00:03:00,660 --> 00:03:06,790
All you have to do is under function prototype like this with a semicolon.

42
00:03:07,680 --> 00:03:14,920
And we can do the same for this one to stop the red lines.

43
00:03:15,080 --> 00:03:16,470
V What s in the column.

44
00:03:16,470 --> 00:03:20,370
You see the line disappeared a K is one more function.

45
00:03:20,450 --> 00:03:26,280
F with this so that you don't get a red line when we use it.

46
00:03:26,310 --> 00:03:30,540
So with paste that semicolon disappeared.

47
00:03:30,740 --> 00:03:36,680
Okay so now we have now own this all of all functions.

48
00:03:36,680 --> 00:03:39,250
That's just one more function left or right.

49
00:03:39,280 --> 00:03:40,370
When we need it.

50
00:03:40,410 --> 00:03:44,090
So we have delay micro zero here.

51
00:03:44,150 --> 00:03:45,420
This values you.

52
00:03:45,490 --> 00:03:48,870
You should leave that dependent on your microcontroller.

53
00:03:48,870 --> 00:03:51,800
You might need to tweak this value to 1 0 0.

54
00:03:51,870 --> 00:03:56,820
If the code is not running appropriately but Karen the mess leaves 0 4.

55
00:03:57,120 --> 00:04:04,080
If you check the key to shoot for far LCD or the data datasheet of your LCD which I presume the market

56
00:04:04,120 --> 00:04:12,610
has the same type of LCD drivers you'd realize that the commands have different amount of delays as

57
00:04:12,610 --> 00:04:22,610
specifically commands 0 1 2 and 3 have different delay amounts compared to the rest of the command.

58
00:04:22,650 --> 00:04:29,580
So what we're going to do is create a condition here to give two delays based on the command that we

59
00:04:29,580 --> 00:04:31,920
are given to the LCD.

60
00:04:31,980 --> 00:04:34,190
We're just going to use an if statement here.

61
00:04:34,200 --> 00:04:43,380
I'm going to say that command is less than 4 which means if it's commanded one two three DeLay give

62
00:04:43,440 --> 00:04:50,490
us a delay of two milliseconds delay merely to

63
00:04:53,500 --> 00:05:00,970
dispel this well ls one hell to delay my crew.

64
00:05:01,260 --> 00:05:07,090
This is based on the data sheets which I do not want to bore you with.

65
00:05:07,090 --> 00:05:13,690
You can open it and check out our data sheets to the additional files with this particular video.

66
00:05:14,560 --> 00:05:21,610
Some data sheets come weights 14 and two milliseconds so based on your microcontroller you might need

67
00:05:21,610 --> 00:05:29,320
to know not based on your microcontroller based on your LCD and you might need to tweak this for two

68
00:05:31,020 --> 00:05:36,820
to delay for to 40 microseconds but it should be well.

69
00:05:37,590 --> 00:05:43,670
So basically this is our LCD do command function.

70
00:05:43,780 --> 00:05:50,740
So now that we have the function we can come back here to use the LCD the command function to initialize

71
00:05:51,130 --> 00:05:52,820
our LCD show.

72
00:05:52,960 --> 00:06:02,250
What we want to do the first thing we want to do as we spoke about is to tell the microcontroller or

73
00:06:02,290 --> 00:06:05,440
to tell the internal registers of the LCD.

74
00:06:06,010 --> 00:06:10,850
What type of LCD we are using and the mode we want to operate it in.

75
00:06:11,410 --> 00:06:20,420
And this entire nation is and capitulated into called 0 x 3 8 and basically what this means is that

76
00:06:21,520 --> 00:06:23,300
we want to operate in a debate.

77
00:06:23,320 --> 00:06:27,980
Remember we can send information in full bits as well as 8 bids.

78
00:06:28,120 --> 00:06:33,390
So we tell in it we want to operate in it and now our particular LCD has to outline.

79
00:06:33,400 --> 00:06:36,640
It has to line display

80
00:06:39,210 --> 00:06:45,700
and it has fallen off and it has fallen off 5 by 7.

81
00:06:45,720 --> 00:06:52,860
So this what this information means for more commands you can check the data sheets they have so many

82
00:06:52,870 --> 00:06:58,000
commands out there you can check later.

83
00:06:58,260 --> 00:06:59,790
We still have this her.

84
00:06:59,880 --> 00:07:06,650
Sure we still have this here because we did not at the prototype of this function up there so cocky

85
00:07:07,100 --> 00:07:08,800
bring it up here.

86
00:07:08,850 --> 00:07:12,940
Paste control V and then semicolon it should disappear.

87
00:07:12,950 --> 00:07:14,090
It's disappeared now.

88
00:07:14,400 --> 00:07:21,930
So with added the first command with telnet you know what we want to Fed data and 8 bids and our LCD

89
00:07:22,230 --> 00:07:26,420
displays to lives in and has a 5 by 7 font size.

90
00:07:26,820 --> 00:07:33,360
So this good the next command is to tell the LCD internal on register to increment the curse up for

91
00:07:33,360 --> 00:07:39,460
rest not too much too early and the code or the command for this is 0 x 0 6.

92
00:07:39,460 --> 00:07:50,660
So all we have to do is LC the upfront new function put it to use policy zero 0 0 6 and medical equipment

93
00:07:50,790 --> 00:07:57,660
for you swore increment automatically.

94
00:07:57,660 --> 00:08:04,020
Finally the last two commands will be to 10 on the display and included display to 10 on the display

95
00:08:05,700 --> 00:08:24,900
LCD command is 0 x 0 F like this and to clear the display issue x 2 a 1 or C to command 2 x 0 1.

96
00:08:25,490 --> 00:08:27,680
So let's put this command here.

97
00:08:27,720 --> 00:08:29,310
Let's put this comment here.

98
00:08:29,520 --> 00:08:37,470
Just call it 10 on display then we'll put another comment here.

99
00:08:37,510 --> 00:08:41,210
Clear display.

100
00:08:41,210 --> 00:08:44,480
So yeah we've covered quite a lot.

101
00:08:44,710 --> 00:08:52,120
We have to write one more function which is the LCD data the data function.

102
00:08:52,120 --> 00:08:54,420
This is the one that would allow us to send data.

103
00:08:54,430 --> 00:08:57,270
Then after that we just start typing our data out.

104
00:08:57,550 --> 00:09:00,300
So we'll take a look at that in the next lesson.
