WEBVTT

00:00.080 --> 00:05.920
This is the solution of the previous activity where you have to start from the previous activity.

00:05.950 --> 00:07.850
So activity number three again.

00:07.850 --> 00:13.910
But this time we are going to put some logs from the Arduino to the LCD screen.

00:13.910 --> 00:17.510
And so first of all, we are going to initialize the LCD screen.

00:17.510 --> 00:25.430
So I'm going to include the liquid crystal library.

00:25.430 --> 00:28.790
So liquid crystal dot H with angle bracket.

00:28.790 --> 00:30.950
And then add some define for the pin.

00:30.950 --> 00:43.550
So LCD is PIN, which is eight four, and then LCD pin which is a five.

00:44.090 --> 00:46.100
And let's actually copy this.

00:47.490 --> 01:01.470
Four more times with d4 d5 d6 D7, which are pins number two, three, four and five.

01:02.910 --> 01:05.370
And so we can now create the LCD object.

01:05.370 --> 01:06.680
So let's create it here.

01:06.690 --> 01:16.560
Liquid crystal, let's name it LCD again with all the pins, so S and then E So make sure you respect

01:16.560 --> 01:17.210
the order here.

01:17.220 --> 01:17.820
Okay?

01:17.850 --> 01:18.870
That's very important.

01:20.040 --> 01:20.970
And then.

01:22.310 --> 01:22.950
Let's go.

01:22.950 --> 01:23.700
Here.

01:24.860 --> 01:25.790
The five.

01:28.700 --> 01:33.380
And D6 and D7.

01:35.300 --> 01:35.840
Okay.

01:35.840 --> 01:45.140
Now in the setup, so we have begin we can also do LCD dot begin with 16.

01:47.020 --> 01:47.530
And to.

01:49.530 --> 01:54.840
So here again, the order doesn't really matter because as soon as the LCD is started, well, you can

01:54.840 --> 01:56.730
start to print something.

01:56.940 --> 01:59.760
And now, well, we're going to use the LCD here.

01:59.790 --> 02:05.400
So let's say that when we send the counter at the same time we do serial.println.

02:05.430 --> 02:09.750
So just after that, maybe we do LCD dot clear.

02:10.320 --> 02:10.440
Okay.

02:10.440 --> 02:16.530
So we clear the screen from anything that was on the screen before we do the LCD.

02:16.710 --> 02:28.350
Set cursor zero zero to go back to the beginning of the screen and we say, let's say LCD dot print

02:28.380 --> 02:29.400
with.

02:30.720 --> 02:32.970
Since counter.

02:35.220 --> 02:35.520
Okay.

02:35.520 --> 02:39.870
And let's do LCD dot print with the counter.

02:40.050 --> 02:46.620
So here, as you can see, if we do a print and then another print where the cursor it starts from zero

02:46.620 --> 02:51.660
zero and then it's going to go to one, two, three, four, five, six, seven, eight, nine, ten,

02:51.690 --> 02:54.240
11, 12, 13, 14.

02:54.240 --> 02:59.530
So we just have two more characters that are possible here.

02:59.550 --> 03:05.410
So basically, as long as the counter doesn't reach 100, we're going to get all the characters.

03:05.430 --> 03:14.510
If you want, you can also do LCD dot set cursor with zero and one.

03:14.520 --> 03:18.600
So basically you're going to print that on the first line and that on the second line, okay, let's

03:18.600 --> 03:20.250
keep it like this.

03:20.490 --> 03:28.440
And now when we receive something here, well, for example, what we could do is directly when we receive

03:28.440 --> 03:30.480
a comment, just print that comment.

03:30.510 --> 03:35.650
Or we could do a different LCD print for each comment.

03:35.740 --> 03:36.000
Okay.

03:36.010 --> 03:37.930
With a custom text that we want.

03:37.930 --> 03:41.410
But here I'm just going to do this LCD dot clear.

03:42.100 --> 03:42.310
Okay.

03:42.310 --> 03:48.430
If I don't do LCD dot clear, everything is going to be written on top of what's what has been written

03:48.430 --> 03:52.360
before, but it's not going to remove the other characters.

03:52.360 --> 03:55.120
So you may have something that is quite weird on the screen.

03:55.120 --> 04:02.080
So that's why when I write something here with the logs, I'm going to do LCD clear and LCD dot set

04:02.980 --> 04:03.230
clear.

04:03.280 --> 04:09.610
So zero zero LCD dot print cmd.

04:10.790 --> 04:11.060
Okay.

04:11.060 --> 04:17.900
So whenever we send something or we receive a command, the screen is going to be cleared and we're

04:17.900 --> 04:21.280
going to get the new log that is printed.

04:21.290 --> 04:23.060
So let's try that.

04:23.060 --> 04:25.940
Okay, I'm gonna upload the code first.

04:25.940 --> 04:29.090
Let's name it activity for.

04:32.610 --> 04:34.720
I'm going to also save this file.

04:34.740 --> 04:36.480
This python file as.

04:37.800 --> 04:40.830
Activity as well.

04:42.050 --> 04:44.480
He even if that's the same code.

04:44.480 --> 04:48.500
And then let's start the Python program.

04:51.570 --> 04:52.890
Okay, so sale Okay.

04:52.890 --> 04:55.320
And you can see here send counter.

04:55.920 --> 04:56.430
Okay.

04:57.520 --> 05:02.440
You can see and we have reset counter and then send counter because well, it goes very fast and we

05:02.440 --> 05:03.490
just received it.

05:03.520 --> 05:06.400
We just receive the command before we send another counter.

05:07.330 --> 05:12.010
You can see up to 20 and then reset, counter send counter.

05:12.130 --> 05:12.610
Okay.

05:12.610 --> 05:16.480
So you can see basically what's happening from the Arduino.

05:18.540 --> 05:20.440
I'm going to kill this.

05:20.460 --> 05:26.940
And so, as you can see, this system is not the best ideal system because, for example, here on the

05:26.940 --> 05:35.550
Raspberry Pi, the logs that we see here are kind of better, but that's always something you can do

05:35.550 --> 05:36.900
to debug a little bit.

05:36.900 --> 05:40.730
And you can see also that it's not just about debugging.

05:40.740 --> 05:45.960
Now you can see that you can control the LCD screen directly from your Raspberry Pi, okay?

05:45.960 --> 05:51.030
Because here you just send some text and you can print that text on the LCD.

05:51.270 --> 05:58.890
So you can already control some Arduino components from the Raspberry Pi going through the serial communication.

05:58.890 --> 06:01.140
And that's the end of this activity.

06:01.170 --> 06:01.950
Number four.
