Loading...
Hi, I'm Rebecca, your computing teacher, and we're going to be having another look at the Sense HAT in this lesson.
So you will need a Trinket account, which you should have already set up with your parent's or carer's permission, or you might be following along with a physical device.
And if you are, I've got mine here.
So if you are, you need to make sure that you are following that safety guidance and that you power down your Raspberry PI computer before you start attaching the Sense HATs on top.
You might have already attached though, from the last lesson, and if it is, then that's okay too.
But if you do need to put it back on, make sure it's fully powered down and that you very, very carefully place that top bit on making sure that it goes right in those holes so that you're not bending any of those pins.
And then once you're happy it's safe and secure on, you then plug it in.
So you mustn't attach things to your Raspberry PI computer without having the power off first, if you are doing that.
So you're going to need your Trinket account, or your Raspberry PI, and you are going to need to make sure that you've got a pen and paper to make any notes that you might need to, and to remove as many distractions as you can so that you can really focus in this lesson.
Once you've got that ready, we can begin.
In this lesson, you will use randomization to append items to a list.
You're going to have to think back quite far now to when you learned about random and choice with programmes and how they work with a list.
And you're also going to have to think back to last lesson on how the Sense HAT works, and how colours work, and how clear works, to see if you can make a bit of a prediction here about what the three possible outputs would be from this code when it's executed.
So pause the video while you have a think about that.
Let's take a look at the answer then.
So all red, yellow or blue pixels will be displayed on the screen.
And if you remember from last lesson, sense.
clear sets the entire LED matrix to a single colour.
So if we just take a look at this code, we're importing the Sense HAT modules that we're going to need, and we're also importing choice from the random module.
So we need those things.
And then we've got three variables, red, yellow, and blue, and we're setting those to those colour values that can be used with the LED matrix.
Then you've then got a list, a list called colours, and we've assigned those three variables to that list.
And then you've got on line 12, colour equals choice colours.
So that's just going to use the random module to pick a random option from that list, colours.
So it'll either pick red, yellow, or blue, and then whatever is being held in that variable, it will then produce it as output on the LED matrix.
So that's why it would be red, yellow, or blue pixels.
So what I want you to do now is use the worksheet.
It's step by step.
It'll step you through how to get going with this.
So I want you use the random pixel colour grid section of the worksheet to create random pixels on your LED display.
So pause the video while you have a go at that.
Excellent, I bet that was fun.
I wish I was doing this lesson , 'cause I really love this exercise, if you haven't realised already.
So hopefully you found that quite fun to do.
So here was the solution then.
If you didn't quite get to the solution, you can now have a go at it.
So just pause the video and take a look at the solution.
And then if you had a go at the explore task, then this was that bit of code that you needed.
And you could also have a look at that using the short link there on the bottom right of the screen there, if you want to have a go too.
Excellent.
Your next challenge then is to make a random pixel alien.
So use the random pixel alien section of your worksheet to create a random pixel alien on your LED matrix.
Pause the video while you have a go.
Brilliant.
Let's see, let's go and take a look at the solution.
Let's just run it and just see what it looks like.
So if you managed to get yours working, then it should look a little bit like this.
So I'm just going to press run.
So you've got that alien and then it should start doing random pixel colours as well on that alien shape.
So you can go and have a look at this code using the short link too.
There's quite a lot of code there to compare it to, so you can compare that to your code and check if you got it right or not.
Your final challenge then is to have a go at turning your sensor into a Magic-8 Ball.
Now, the worksheet gives you instructions to support you through this, and you can have a go at this yourself, and I will show you the solution in a few moments, but make sure you pause the video and that you have a go at this first.
Again, it's quite a fun task to have a go at.
So use the Magic-8 Ball section of your worksheet to create a Magic-8 Ball that works with the Sense HAT.
Pause the video while you have a go.
Super, and I'd love to see if you've actually edited some of those responses too, to see you can have different responses, couldn't you? Rather than the ones that are actually on there, but here is my solution that I came up with.
So you can pause the video now while you check my solution with yours.
With all these things, as we're getting much, much further, into these programming challenges, you are going to programme these with slightly different solutions and that is okay.
And I'm going to keep saying that over and over again, 'cause we're all human and we all do things differently.
We're not going to do things perfectly or exactly the same.
But here's my code for my solution.
So if you need some help and you want to just take a look at that and use bits of those code in yours, then you can, or just to confirm that you're on the right track, use it for that.
So pause the screen while you have a look.
Excellent.
And that is everything.
I hope you've really enjoyed using the Sense HAT.
It is something that I really love to do 'cause there's all sorts of things you can do with it once you start to playing around with it.
If you'd like to, please ask your parent or carer to share your work on Instagram, Facebook, or Twitter, tagging @OakNational and #LearnwithOak.
You might want to show your Magic-8 Ball or your alien.
You can share that with me so that I can see what you've been getting up to in this lesson.
And I look forward to seeing you for the next lesson.