 So what can microbit do with scratch? It has a bunch of features, but not all are made equal when it comes to scratch Well stick around because in this scratch microbit tutorial We'll go through the buttons the LEDs the pins and the accelerometer through each code block in the project editor All this coming your way Hello world surfing scratchy here teachers surf a programmer bringing you the goodness of learning to code through video Tutorials if that sounds like something that you're into consider hitting that subscribe button Hit the show more button down below to check out a bunch of links that relate to this video If you don't yet have a microbit, you can show your support for this channel by getting yours through using the link in the description below But hey, let's go suss out those microbit blocks. Here we are in the scratch project editor You can see our microbit is connected We've got our microbit category selected and all of our blocks here to explore I've made this scratch microbit simulator, which isn't perfect But it'll do the job to simulate some of these blocks in action here on the screen I'm also going to be recording an actual microbit alongside it Let's go check out the first block of the microbit blocks category and that's this event hat block here So this event hat block refers to the button presses. We can do something when the A button is pressed We can do something when the B button is pressed We can also do something when either of those buttons are pressed But no, we do not have an option for when both buttons are pressed. Okay, let's do something on these button presses I'm gonna go get this stack block here This display text stack block and what that will do is it will illuminate this text by the LEDs of the microbit So if we connect it on an A button press, let's display the text A and on a B button press Let's display the text B. Okay. I've got the microbit here And we're just going to press the A button and you can see the A has illuminated now I'm going to press the B button and the B button has now illuminated I mentioned before that there is no when A and B is pressed at the same time We can easily simulate that using these Boolean blocks here So we can get this Boolean block of when the A button is pressed And we can also get the Boolean block of when the B button is pressed And what we can do is wrap that inside an operator and Boolean block So if we go when A is pressed and when B is pressed, then we'll do some stuff So let's stick that inside of out your statement and then we can display the text both Okay, I've got the microbit here. I'm just going to press both buttons at the same time And there we go. We've got the text cycling through saying both All right, let's check out the next event block And that's when they're moved, shaken and jumped And this all relates to that accelerometer or the motion sensor of the microbit So the first block here is when moved It's basically just when the microbit is handled Show you that by attaching this display block here So when the microbit is moved, we will display this image Okay, I'm just going to go and reach for the microbit here And you'll see as soon as I touch it, it illuminates into that shape Okay, so let's check out the next event and that is when shaken We're going to display all the LEDs when we shake it We're just going to head across over into the microbit now Here we are. Now you have to give it quite a vigorous shape for this to work Here we go. There they all are The next event is the when jumped event Now that is when the microbit goes up and then it goes down Let's jump across the microbit to see that in action Okay, microbit goes up and then down Here we go. Okay, let's look a little bit more at this display stack block So if you click on the drop down menu, you'll see that you've got access to these LEDs You can press the all blank ones to reset it And you can press the white ones to illuminate them all Depends on which way you like starting from I like starting with the blank slate What we're going to do now is display four images to represent all the tilts I'm going to show an arrow You can click and hold these down to just illuminate them Here's duplicate Okay, so we've got our four arrow directions here, which is awesome And that's going to really help us to understand the tilt So let's look at the next block here And that is when the microbit is tilted Yeah, if you go to the drop down menu here, you've got front, back, left, right and any tilt So any tilt is almost like that move hat block So when we tilt to the front, let's signify that by using the front arrow When we tilt to the back, let's signify that with the down arrow here When we tilt to the left, let's go left And when we go right, let's look at the right arrow here I'll just clean all this up Okay, let's go check this out on the microbit I have it in my hand I'm going to tilt it towards me and the arrow changes towards me I'm going to tilt it to my right, to my left, and now forward This works best when the microbit is parallel to a surface Not when it is perpendicular like it is now You can also use the Boolean equivalence of these when tilted events We also have these reporter blocks for our tilt angles We can check out the front, the back, the left and the right values Now if we look over here on the stage I've got that represented in these variables here So I'm just going to go back across to the microbit And as I move the microbit, you can see those values are updating Which is pretty neat Now arrow of the microbit is not updating because I just got rid of those blocks I've skipped over one of the blocks and that's clear display I hope it's pretty clear what that one does That will just clear all the LEDs Which one happens when I press it All right, so let's check out the final hat block And that is when the pins are connected So we can detect when the zero pin, the one pin, or the two pin has been connected And we'll be using the ground pin to complete the circuit To demonstrate this, I've got a jumper cable that I'll be using And let's connect up all the pins So what I need to do here is I need to use my jumper cable to touch the ground pin And when I'm touching the ground pin, I can also touch the zero pin And it will illuminate to zero I can use it to touch the one pin And I can use it to touch the two pin Never use the three volt and the ground together I've got a link down below in the description that explains these pins in more detail To round off this tutorial, I want to talk a little bit more about these LEDs And specifically this display stack block So you'll see that this stack block here has a space for a reporter block And that's cool because what we can do Is we can go in and pass it a list Now why would we want to do that? Well, an LED light is either on or it's off So it can be a zero or a one That's how this works So we can go and create a list of 25 slots That refer to each of these LEDs And we can turn it on and we can turn it off I've gone ahead and created a list variable to show this Put the LEDs list here on the screen And I've also got the LEDs reporter block If we click it, you'll see that it's just got all those numbers in a long line All those zeros I can drag that inside off the display I can go in and I can change the first space to a one And when I do that, it turns on Which is amazing Now in this simulator, what I've got ahead and done Is I've made all these LEDs clickable So you can go in and you can turn these on and off And you can watch all the LEDs update through here Why might this be useful? You might be asking We can also export our list And that means that we can store the drawing And if we ever want to upload the drawing again We can do that through an import Here I'm going to get the scissors that I created earlier I'm going to open that And there is my scissors display What I've gone ahead and done is Wrap that display blood block inside a forever block When the green flag is clicked So if we go in and upload that scissors image You'll see that we've got the mark bit on the screen now And we open it We've got the scissors right there So what you can go ahead and do You can go and create all these different lists With these 25 values And you can have these predefined images That you could reuse throughout your project Just a word of caution If you explicitly do this And overwrite the display block You'll never be able to display text This simulator doesn't handle text Perhaps I can leave that as a challenge For you to remix this simulator And make it handle text Drop me a comment down below If you'd be interested for me to create a video On how I created this simulator It's time for a scratchy question And I want to know, do you have any outrageous or crazy ideas To use Scratch and Marker Bit together? Share yours in the comment section below Or we might even start a collaboration Hey, thanks for checking out this scratch mark bit tutorial Like, subscribe, ring the bell if you're new around here And have a scout some other content On your screen right now Show your support for Surfing Scratcher By checking out exclusive content on my Patreon page My funky red bubble teas Or by joining the mailing list All links below in the description But until then I'm off to go find a wave I'll catch you in the next one