WEBVTT

00:00.110 --> 00:04.280
Here is yet another activity for you to practice more on cereal.

00:04.280 --> 00:07.820
And in this activity, here is what you are going to do.

00:08.180 --> 00:11.690
So from the Arduino, you are going to send a counter.

00:11.690 --> 00:13.850
So you're going to initialize a counter.

00:13.880 --> 00:23.000
Okay, so init counter and then send it every 500 milliseconds.

00:23.000 --> 00:28.880
So every time of course you're going to increase the counter and so increment it.

00:29.570 --> 00:32.780
So you send zero, one, two, three, etcetera.

00:33.440 --> 00:33.680
Okay.

00:33.680 --> 00:40.790
And that of course from the main loop on the Raspberry Pi, what you are going to do is of course receive

00:40.790 --> 00:42.800
and print the counter.

00:43.100 --> 00:44.840
So that is the first action.

00:45.140 --> 00:48.380
Now this would be a little bit too easy for you at this point.

00:48.380 --> 01:00.590
So what you're going to do is also that every 10s, so every 10s you are going to reset the counter.

01:00.590 --> 01:05.150
So to reset the counter, you are going to need to send a special command to the Arduino.

01:05.150 --> 01:10.490
And on the Arduino is that when you receive when receive

01:12.830 --> 01:19.700
reset counter command, then you reset the counter, of course, so you reset it to zero.

01:19.700 --> 01:24.740
And the thing is that those two actions here are completely independent.

01:24.770 --> 01:25.190
Okay?

01:25.190 --> 01:32.390
So here, as you did in the previous activity, you're going to send the counter every 500 milliseconds

01:32.420 --> 01:39.650
without using delay and you're going to in parallel and in a different action check if you have received

01:39.650 --> 01:44.540
that reset counter comment on the Raspberry Pi, you're going to do the same.

01:44.660 --> 01:45.200
Okay.

01:45.200 --> 01:51.710
So in Python, you are not going to use time dot sleep for 10s, of course, because if you do that,

01:51.710 --> 01:56.270
you're not going to be able to print the counter for 10s.

01:56.300 --> 01:56.840
Okay.

01:56.840 --> 02:04.040
So in Python you're going to need to do also a non-blocking action every 10s with basically the same

02:04.040 --> 02:06.980
structure as we did previously on the Arduino.

02:06.980 --> 02:14.690
So in your while true in the void loop of your Python program, the first action or the second.

02:14.690 --> 02:15.560
Okay doesn't matter.

02:15.560 --> 02:22.640
The order is to receive and print the counter and the second action is to reset the counter whenever

02:22.640 --> 02:24.470
you have past 10s.

02:24.500 --> 02:24.950
All right.

02:24.950 --> 02:27.680
And I will see you in the next video for The Solution.
