1
00:00:00,780 --> 00:00:01,420
Hello.

2
00:00:01,500 --> 00:00:02,720
Welcome back.

3
00:00:02,730 --> 00:00:09,060
So this is this state of Iowa GPL u in its function or subroutine.

4
00:00:09,240 --> 00:00:11,670
We initialize clock access.

5
00:00:11,670 --> 00:00:18,100
And over here we set GPL u p f one as output.

6
00:00:18,690 --> 00:00:22,930
And then we digitally enabled P.F. 1.

7
00:00:22,950 --> 00:00:34,020
Now we're going to unlock our PFC row and then we can add green as another output and then add the switches.

8
00:00:34,020 --> 00:00:38,890
So I'm gonna come over here right after initializing clock.

9
00:00:38,910 --> 00:00:41,600
I'm going to unlock it.

10
00:00:41,660 --> 00:00:46,140
Oh she went on lock PFC through by saying Lord

11
00:00:49,410 --> 00:00:51,090
are 1 with the GPA f

12
00:00:54,430 --> 00:01:00,520
0 she could register and then load r 0

13
00:01:03,290 --> 00:01:07,670
we did lock key which we could lock a key simply lucky

14
00:01:12,940 --> 00:01:14,600
and then start a.

15
00:01:14,840 --> 00:01:18,460
So I'd say store our 0

16
00:01:21,810 --> 00:01:22,220
R1

17
00:01:29,580 --> 00:01:30,000
right.

18
00:01:31,500 --> 00:01:36,510
So this would unlock this will not PFC or for us.

19
00:01:36,510 --> 00:01:40,310
So now once we've done that we've got to commit.

20
00:01:42,960 --> 00:01:45,120
I'm gonna come over here and say

21
00:01:47,810 --> 00:01:58,470
Lord oh Lord a comet's register Lord I want a course GPA U F C R R and then I'm simply going to move

22
00:02:00,650 --> 00:02:01,770
or simply use

23
00:02:05,660 --> 00:02:12,800
user x f f over here and then store out as you are one

24
00:02:18,000 --> 00:02:18,660
right.

25
00:02:19,530 --> 00:02:22,980
So we've unlocked and we've committed.

26
00:02:22,980 --> 00:02:31,650
Next we have our direction register here over here we just set in P F one as output.

27
00:02:32,460 --> 00:02:39,150
So what I'm gonna do is I'm going to add the green LCD and to add that in C language I'll simply add

28
00:02:39,150 --> 00:02:46,410
this and do Ellie de Green and this also will be set over here to add it's in assembly.

29
00:02:46,410 --> 00:02:48,300
I'll have to use the O operation

30
00:02:53,560 --> 00:02:54,230
um

31
00:02:57,600 --> 00:03:00,510
so I'm gonna start off first.

32
00:03:00,660 --> 00:03:05,400
I can't read with the current value of our zero.

33
00:03:05,730 --> 00:03:13,560
Once I start I'm going to perform another or iris zero then a green.

34
00:03:13,560 --> 00:03:17,220
This would add green to it.

35
00:03:17,220 --> 00:03:17,780
Right.

36
00:03:17,800 --> 00:03:20,530
As simple as that.

37
00:03:21,110 --> 00:03:22,870
So does the direction register.

38
00:03:23,030 --> 00:03:29,510
Remember to set a pin to to output in the direction register you've got to set the bit to 1.

39
00:03:29,510 --> 00:03:35,030
That's why we're doing this to set to input you've got to set it to 0 but because the default state

40
00:03:35,030 --> 00:03:35,600
is 0.

41
00:03:35,600 --> 00:03:41,580
I'm not going to set anything for the switches caused by default I already input.

42
00:03:41,690 --> 00:03:45,360
That is why I'm only doing it for the M for the output.

43
00:03:45,380 --> 00:03:51,790
The red and green lady now on digital enable from digital enable to digitally enable a pin you've got

44
00:03:51,790 --> 00:03:54,970
a set it built into digital enabled register to 1.

45
00:03:54,980 --> 00:04:02,800
So we've got a set one for the LCD screen one for elderly red one for switch one one for switch to.

46
00:04:03,260 --> 00:04:11,650
So this was going to be a little red like this in C language a Lady Green

47
00:04:16,790 --> 00:04:24,720
switch one switch to this is going to be like this right.

48
00:04:24,860 --> 00:04:31,970
So I can either use a plus sign a lady red plus a lady green plus which one plus switch to or I can

49
00:04:31,970 --> 00:04:35,170
simply use the operator the.

50
00:04:35,330 --> 00:04:42,590
Yeah perform an operation so I'm simply going to do this and then this becomes

51
00:04:45,850 --> 00:04:46,740
Lady Green.

52
00:04:46,800 --> 00:04:50,680
This becomes a sloppy one.

53
00:04:50,680 --> 00:04:51,430
This becomes

54
00:04:54,300 --> 00:04:56,210
messed up too right.

55
00:04:57,710 --> 00:05:01,510
So once that is done we need to set the um the pool up.

56
00:05:01,640 --> 00:05:06,570
We need to go to the pool up register and sets the pool up for our switches.

57
00:05:06,590 --> 00:05:07,990
I'm gonna come over here.

58
00:05:08,350 --> 00:05:08,770
Okay.

59
00:05:08,780 --> 00:05:10,120
I forgot the C language.

60
00:05:10,130 --> 00:05:11,260
I've not done that for a while.

61
00:05:11,280 --> 00:05:20,620
Also GPL you f pull up register and I'm going to enable it for switch one and switch to like this.

62
00:05:20,650 --> 00:05:40,910
So an assembly load R1 because GPA F P you are on the score R and then load r 0 are 1 and then we do

63
00:05:40,910 --> 00:05:44,550
an all operation or r 0

64
00:05:47,560 --> 00:06:04,970
with switch one and then all our 0 we switch to and then we can store no SDR r 0 R1 and then we return

65
00:06:05,060 --> 00:06:09,990
would be X a la like this okay.

66
00:06:10,380 --> 00:06:10,840
Right.

67
00:06:11,280 --> 00:06:14,620
So we're looking good now.

68
00:06:14,880 --> 00:06:24,630
Now we can um we have to write a subroutine to two to root D pin to read the buttons I should say I'm

69
00:06:24,630 --> 00:06:26,280
going to delete a while

70
00:06:29,380 --> 00:06:36,460
I'm gonna delete or delay and blink subroutines here we don't need them I'm gonna write a new subroutine

71
00:06:36,460 --> 00:06:37,630
for GPL you read

72
00:06:48,250 --> 00:06:52,480
and I'm going to load the data register load

73
00:06:59,920 --> 00:07:06,880
GPL you f on this court data on the score register then

74
00:07:10,150 --> 00:07:20,620
load C row are 1 here and then I'm going to check I'm gonna check if this switches suppressed and I

75
00:07:20,620 --> 00:07:26,260
will do that by course the content of the data register is going to be an R1 so I'm gonna use the end

76
00:07:27,130 --> 00:07:35,530
operation I'll end r 0 the content of Iris Zero which I you a check without data on pressed or not

77
00:07:38,740 --> 00:07:40,550
when I use three or approaches.

78
00:07:40,660 --> 00:07:45,420
Just think of the third one as the destination when I do this.

79
00:07:46,920 --> 00:07:48,980
It's the same as doing this right.

80
00:07:49,000 --> 00:07:52,350
Do not be confused okay.

81
00:07:52,390 --> 00:07:59,010
So I'm going to say check PFC row and pay for what I do pressed or not.

82
00:07:59,620 --> 00:08:00,010
Right.

83
00:08:00,040 --> 00:08:06,560
And the result is going to be put the output of this and operation is going to be an Irish euro.

84
00:08:06,910 --> 00:08:11,440
So I'm gonna do B X LR to return from the subroutine

85
00:08:14,320 --> 00:08:14,910
right.

86
00:08:21,930 --> 00:08:22,300
Okay.

87
00:08:22,450 --> 00:08:26,210
So um let's see what we have.

88
00:08:26,260 --> 00:08:28,240
This is our main.

89
00:08:28,600 --> 00:08:31,270
We start off by GPL U in it.

90
00:08:31,570 --> 00:08:33,730
We don't we no longer have blink.

91
00:08:34,000 --> 00:08:42,070
But what we have is GPL you read so I'm gonna come over here once we've initialize our GPL you will

92
00:08:42,070 --> 00:08:45,580
read it by doing branch to GPI you read

93
00:08:49,180 --> 00:08:50,630
on this will read both.

94
00:08:50,740 --> 00:08:52,470
Um this will read on what you call it.

95
00:08:52,500 --> 00:08:56,640
Both of the the switches and the results is going to be in Irish euro.

96
00:08:56,640 --> 00:08:59,790
So now let's compare what is in Irish euro.

97
00:08:59,900 --> 00:09:01,820
So I'm going to use this GMP instruction.

98
00:09:01,830 --> 00:09:07,130
Compare the content of Irish euro which switch pressed

99
00:09:14,180 --> 00:09:21,360
and then we'll say if so if it is switch one pressed then we say BQ here.

100
00:09:21,470 --> 00:09:26,390
If a switch one press then we're going to create another subroutine for what we want to execute.

101
00:09:26,390 --> 00:09:28,270
In the case of switch one pressed.

102
00:09:29,030 --> 00:09:35,830
So I'm gonna come down here and outputs which one pressed here.

103
00:09:35,880 --> 00:09:36,690
Switch one.

104
00:09:37,210 --> 00:09:38,000
Yeah.

105
00:09:38,150 --> 00:09:40,730
And what we want to do is turn on the red LCD.

106
00:09:42,860 --> 00:09:44,990
So sorry go there.

107
00:09:46,310 --> 00:09:48,740
So I'm simply going to move the red LCD

108
00:09:51,420 --> 00:09:54,000
simply going to say move

109
00:09:57,300 --> 00:10:04,740
I wish you pushed uh put this into our sewer a little red and I'm going to branch into another subroutine

110
00:10:04,740 --> 00:10:12,600
that would I would turn on the LCD which we shall call a lady on a lot of branch and going on here and

111
00:10:12,600 --> 00:10:12,930
then

112
00:10:15,660 --> 00:10:24,180
um we can return to the um to loop once we've done this once we've executed and turn on the LCD we want

113
00:10:24,180 --> 00:10:33,120
to return to the top of the main loop while one loop so see a b loop over here and I'm gonna put loop

114
00:10:33,120 --> 00:10:35,720
here this label here right.

115
00:10:35,940 --> 00:10:45,880
So we we have to implement a lady on we have LCD on over here this reads the um

116
00:10:48,970 --> 00:10:54,100
this reads our data register and then okay.

117
00:10:54,160 --> 00:11:02,230
We've got a delete this and yeah this is our lady on and I changed a spelling I made it into a lady

118
00:11:02,260 --> 00:11:03,680
on like this.

119
00:11:03,670 --> 00:11:09,430
So if so which one is price we're going to put a lady red into our zero.

120
00:11:09,460 --> 00:11:10,230
Right.

121
00:11:10,270 --> 00:11:15,010
So then our jury is gonna come to early on and then we take what is in our sewer and put into a data

122
00:11:15,010 --> 00:11:18,800
register and in effect the red readily do turn on right.

123
00:11:18,820 --> 00:11:21,750
This what we get if switch one is pressed.

124
00:11:22,360 --> 00:11:29,890
Okay now let's do the same for switch to when I say RCMP

125
00:11:33,530 --> 00:11:45,060
are 0 switch to pressed BQ on this call switch to.

126
00:11:45,140 --> 00:11:47,480
So we're going to right switch to here

127
00:11:54,370 --> 00:11:57,620
this should be switch one this is switch to

128
00:12:00,270 --> 00:12:14,830
and we start off by moving the green LCD move our zero LCD green and then Bill and a score early on

129
00:12:15,980 --> 00:12:19,170
and then we print Park to the top of the loop to start again

130
00:12:24,220 --> 00:12:25,500
right.

131
00:12:25,590 --> 00:12:26,620
So now let's check.

132
00:12:28,720 --> 00:12:34,360
Um we've checked the switch one switch to and then um I think I can leave it here.

133
00:12:34,380 --> 00:12:36,140
I'll leave it for your assignment.

134
00:12:36,150 --> 00:12:41,060
I'll leave on exercise for you to implement both pressed and no price.

135
00:12:41,060 --> 00:12:44,660
What should happen if both of them are pressed or if none of them is pressed.

136
00:12:44,700 --> 00:12:47,340
That will be your exercise for this lesson.

137
00:12:48,360 --> 00:12:49,860
So let's see what we have.

138
00:12:52,300 --> 00:12:52,770
Okay.

139
00:12:52,810 --> 00:12:57,120
After switch to I'm gonna branch back to loop so I'm gonna be here

140
00:13:01,210 --> 00:13:01,690
okay.

141
00:13:03,070 --> 00:13:04,460
Let's pull it and see what we have.

142
00:13:06,190 --> 00:13:06,750
Okay.

143
00:13:06,790 --> 00:13:08,540
Click it to build.

144
00:13:08,600 --> 00:13:14,720
I've caught one error it says switch one not defined

145
00:13:20,450 --> 00:13:23,470
here I put two underscores here.

146
00:13:24,010 --> 00:13:28,000
Let's build to peel successfully installed onto the board

147
00:13:31,390 --> 00:13:33,550
it's finished downloading.

148
00:13:33,560 --> 00:13:41,380
As you can see when I press this the green LCD is on when I press this the red LCD on green red green

149
00:13:41,710 --> 00:13:44,830
red green red light.

150
00:13:45,160 --> 00:13:51,550
So like I said for your exercise I would like you to implement what happens when both buttons are pressed

151
00:13:51,970 --> 00:13:53,900
and when none of them is pressed.

152
00:13:53,950 --> 00:13:55,080
None of them is pressed.

153
00:13:55,090 --> 00:13:58,300
I would like for you to turn off the LCD.

154
00:13:58,300 --> 00:14:04,270
Now you can see that the last LCD the last one that I pressed is still on on the board.

155
00:14:04,420 --> 00:14:09,640
So if nothing is being pressed I'd like for you to implement a subroutine though.

156
00:14:09,640 --> 00:14:10,600
Turn it off.

157
00:14:10,600 --> 00:14:18,160
And if both are pressed I'd like for you to implement you know to turn on the blue LCD or turn on both

158
00:14:18,220 --> 00:14:20,590
LCD when they're both pressed at the same time.

159
00:14:21,130 --> 00:14:25,630
And if you face the questions with regards to the exercise just let me know and I'll see you in the

160
00:14:25,630 --> 00:14:26,290
next lesson.

161
00:14:26,290 --> 00:14:27,030
Have a nice day.
