1
00:00:06,180 --> 00:00:13,790
In this lecture, I'll show you how to use the new pixels which are individually addressable AGP these

2
00:00:14,160 --> 00:00:20,500
in this example, and using a module from other fruit that contains eight now pixels.

3
00:00:21,210 --> 00:00:27,990
The nice thing about new pixels is that the micro python firmware contains a built-In driver.

4
00:00:28,470 --> 00:00:32,940
So there's nothing else that you need to install and there's nothing else you need to Google around

5
00:00:32,940 --> 00:00:33,710
and find.

6
00:00:34,080 --> 00:00:40,520
So you simply import the nail pixel module and you're ready to go.

7
00:00:40,530 --> 00:00:46,320
And here's the example here, which I also referenced in my example script.

8
00:00:47,570 --> 00:00:54,680
In terms of the way that is connected, the pixel to the E.S.P 32, I'm just going to unplug it so we

9
00:00:54,680 --> 00:00:59,450
can see in the back there are four pins, but really just three pins that you need to connect to the

10
00:00:59,510 --> 00:01:03,280
ground, the data input pin and the five pin.

11
00:01:03,560 --> 00:01:09,650
So obviously five votes spend goes to the final pin on the right to ground across the ground.

12
00:01:09,800 --> 00:01:15,670
And for the end, you can choose whichever port you want.

13
00:01:15,830 --> 00:01:24,440
In my case of connected to your 13, which is not even close to the five-fold pin, it makes it easier

14
00:01:24,440 --> 00:01:27,830
to make short length connections.

15
00:01:28,010 --> 00:01:28,390
All right.

16
00:01:30,200 --> 00:01:32,630
Have a look at the example sketch.

17
00:01:33,260 --> 00:01:36,370
Here are the connections that I'm using in this example.

18
00:01:36,740 --> 00:01:45,170
Have got links to the appropriate documentation for the pixel driver and having a look at the header

19
00:01:45,380 --> 00:01:51,950
of my program on importing the various modules, including random, since as you can see here, there's

20
00:01:52,070 --> 00:01:54,920
a random pattern of colors that appears.

21
00:01:55,820 --> 00:02:04,910
I create the PIN object here for the data input pin and then I'm passing that over to the pixel constructor

22
00:02:05,900 --> 00:02:11,620
so that I can create the pixel object in my example.

23
00:02:11,660 --> 00:02:18,110
As I said, I'm using our module from other Frood that contains eight new pixels on it.

24
00:02:18,320 --> 00:02:20,420
Hence of code number eight here.

25
00:02:20,420 --> 00:02:23,570
And the second parameter of the picture constructor.

26
00:02:25,010 --> 00:02:32,750
Once you have the picks or object, you can treat it as an array and address each one of the nail pixels

27
00:02:33,080 --> 00:02:33,930
individually.

28
00:02:34,190 --> 00:02:41,510
So this example here, I'm going for the first pixel C zero, index zero, and I'm passing a color to

29
00:02:41,510 --> 00:02:41,720
it.

30
00:02:42,080 --> 00:02:47,360
And therefore, as I said, you can individually address each one of these no pixels.

31
00:02:47,690 --> 00:02:51,380
I'm actually going to do this in a moment on this show down here.

32
00:02:52,220 --> 00:02:59,510
Once you finish with setting the individual pixels, you call the right function and then the each picture

33
00:02:59,720 --> 00:03:03,590
will display the configured color in the buffer.

34
00:03:04,460 --> 00:03:08,090
I'm calling Buffer here, but of course, not doing anything because I haven't said anything.

35
00:03:08,090 --> 00:03:09,800
So I'm just going to comment that out as well.

36
00:03:10,520 --> 00:03:14,420
So in this example, we just go straight into this infinite loop.

37
00:03:14,870 --> 00:03:22,190
I have a for loop that goes around and programs each one of the Nhill pixels individually.

38
00:03:22,520 --> 00:03:33,230
Then for each Nael pixel x, which comes out of the loop structure, I just pick a color for each hajib,

39
00:03:33,260 --> 00:03:34,130
red, green, blue.

40
00:03:34,490 --> 00:03:41,040
I'm going from zero to 10 here in order to keep the intensity of the light that is coming out of the

41
00:03:41,250 --> 00:03:43,000
pixels to low.

42
00:03:43,310 --> 00:03:52,580
The maximum is 255, but it's almost impossible to look at the actual pixels in room lighting conditions

43
00:03:52,580 --> 00:03:53,710
without going blind.

44
00:03:54,080 --> 00:03:57,440
Now, pixels, very powerful light source.

45
00:03:57,560 --> 00:04:01,760
So you'd be able to see them out in broad daylight as well.

46
00:04:02,210 --> 00:04:08,150
But if you're planning to use your new pixels indoors, just tone it down a little bit by using our

47
00:04:08,150 --> 00:04:11,240
smaller numbers for RGV.

48
00:04:11,930 --> 00:04:12,370
All right.

49
00:04:12,650 --> 00:04:17,320
So I'm programming each now pixel individually with a random color.

50
00:04:17,510 --> 00:04:23,240
And once I go through the loop and all of the pictures are programmed, I call the right function and

51
00:04:23,240 --> 00:04:28,480
that will pass the information off to the actual no pixels and create that color.

52
00:04:28,970 --> 00:04:37,250
And I stay there for 60 milliseconds and I go through a similar loop and turn all of the pixels off

53
00:04:37,550 --> 00:04:44,120
so that I can see the effect of the momentarily of situation for 15 milliseconds.

54
00:04:44,120 --> 00:04:47,300
Just to make that blink kind of effect.

55
00:04:47,840 --> 00:04:52,130
You can try it a few different other effects if you're interested in creating different patterns.

56
00:04:52,610 --> 00:05:00,720
And this is the effect of this random color generator as it looks in the eight Nhill pixel module.

57
00:05:01,400 --> 00:05:03,550
Just wanted to show you a little thing here on this.

58
00:05:03,570 --> 00:05:08,450
You're going to hit control, see to cancel out of the program.

59
00:05:09,470 --> 00:05:10,970
And I'm just going to.

60
00:05:13,190 --> 00:05:15,950
Use the shell.

61
00:05:17,420 --> 00:05:24,080
I could do a little bit of experimentation, so I've imported no pixels, I'm going to create a pin

62
00:05:24,090 --> 00:05:31,670
object just copying from a program and then the pixel object as well.

63
00:05:31,920 --> 00:05:36,510
And I'm going to go and turn on just enough pixel zero.

64
00:05:37,380 --> 00:05:41,550
Actually, I'm going to turn them all off first, because as you can see from the previous example,

65
00:05:41,550 --> 00:05:42,620
they are all running.

66
00:05:43,050 --> 00:05:48,630
So let's do this with some kind of copy of this code for the loop so that if you type it in.

67
00:05:49,670 --> 00:05:53,720
And then all of the pixels of.

68
00:05:55,450 --> 00:05:58,730
Double enter and then call the write function.

69
00:06:00,460 --> 00:06:00,910
OK.

70
00:06:00,980 --> 00:06:08,350
The pictures are now of then less 10 pixel at index zero on.

71
00:06:08,410 --> 00:06:10,310
So this is going to be AGP.

72
00:06:10,330 --> 00:06:13,200
It's going to be blue at two hundred intensity.

73
00:06:13,900 --> 00:06:15,400
Just bring back.

74
00:06:15,580 --> 00:06:16,090
Right.

75
00:06:16,690 --> 00:06:17,740
And there is.

76
00:06:19,070 --> 00:06:25,090
The new picture with day or index zero as to the last one.

77
00:06:30,500 --> 00:06:37,730
So this is going to be mostly red with a little bit of blue in it and call the right function again,

78
00:06:37,850 --> 00:06:41,480
the kind of pink, I think.

79
00:06:42,560 --> 00:06:50,310
OK, so that's basically how you go about individually creating colors or assigning colors to each pixel.

80
00:06:50,660 --> 00:07:02,570
It can also get the color of a individual pixel by using this notation to just read or extract the colors

81
00:07:02,570 --> 00:07:06,070
for it to be from no pixel position zero.

82
00:07:06,770 --> 00:07:07,970
And that will give you.

83
00:07:12,320 --> 00:07:15,180
So they are a zero, the G zero.

84
00:07:15,200 --> 00:07:22,690
Let's check out the blue said there would be just as multiple assignment in a single line of code so

85
00:07:22,700 --> 00:07:28,040
I can extract the current colors of the particular nail pixel.

86
00:07:28,880 --> 00:07:29,290
All right.

87
00:07:29,390 --> 00:07:30,130
It's about it.

88
00:07:30,260 --> 00:07:34,610
So that's how you can use the new pixels with your DP 32 and.
