Coding Lesson 1 - Introduction to Coding
Feb 23, 2021
Hi, I'm Dakota deal with the patch office here in Spencer West Virginia and today we're going to be learning about coding. So let's get started. First we want to open up our web browser and we want to type in the site code dot org. If I can type right. Here is the main website that we will be using for our artificial intelligence or our AI coding lessons once we get to this website. We want to scroll down and see the learn at home tab. We want to do an hour of code, which will bring us to many, many different options for different types of code. We want to scroll down to where it says classic maze. This one is the this would be a basic introduction to the code. Now we do have videos here that people have recorded for themselves to show you different obstacles, four different parts of this, but we don't want to watch these, so as you can see, we have our little instructions up here. We have our bird asking us to help him catch the naughty pig stack a couple of move forward blocks past and press around to help me get there. Or move forward block, if we hit our run, we'll move our bird forward. So we want to add one. And we have a workspace over here. That will tell us the limit, it takes to get to our objective. Now that we've added one block, let's hit run. And as you can see, the puzzle has been completed. Let's move on. Now number two, it does tell us to do the same thing. But later on in this, it will tell us to do different blocks with the turn left in the turn right. So let's go ahead and add in our blocks for moving forward. And hit run. As you can see, our little bird had moved forward. Now here's where the turn blocks come into play. We've already seen our move forward, which moves our bird forward one block. So here we want to add another one. And as you can see, if we move forward again, we're going to hit a obstacle. We don't want to do that. So here we want to turn the right direction. So here we want to turn to the right. And then move another forward. As you can see, our little demonstration there are little bird will turn any direction, chooses. As long as it's in the source code. Then we want to add another block over it. Here it gets a little bit trickier. We need to move forward. So if we hit one, it only moves one. So we need to use the blocks, our turn blocks to our advantage. Here, if we move right, we're going to end up hitting this block down here and ending us to fail. So we want to hit the left block to go up. And then we want to move forward. Let's test this. Now that we're facing upwards, we need to turn to a different direction. Here we want to turn to the right to aim towards the pig. So we are going to add a right, and we move forward. In the same concept goes here, we need to turn, move, and turn, and move. So we don't want to move forward just yet. We want to turn move, turn, move three. We want to turn left, and then we want to move. Let's go ahead and click run. As you can see, we did not move down. So we need to click and change these. We did mess up again. It's all about trial and error. To make sure that we get the right code. Now here, he's going to teach us about three repeat loops. We'll repeat loops do. Is it repeats the same action? As we put a single block into this. So if you wanted to repeat as many times, you just would type in a number. For example, the 5 was there. So we're just going to keep 5. And we're going to put our move forward block in. Let's test this. Now as you saw in the that we didn't move forward as the block intended us to. So in this one, we need to have a turn. So in the we need to turn left. And then put our block in. If you put a block on the outside, it will not repeat. But inside will repeat. Now I believe this is the last frame for this one. So what we need to do is repeat at least 5 times, and then we need to put one in the middle. Again, what's on the inside is what's important in that repeats. So we need to put two repeats and move forwards. Now as you saw, we need to count the spaces, so we don't run into objects. So we accidentally move 5, but we need to actually in turn move four. So this is where we start, we need to count to three, four. So we replace this with the number four. And then we would turn and then we would move. Let's test this. These blocks are incredibly helpful when you were building any piece of code. For any script. When a block is turned a different color from what it is, this block can not be deleted. So this block is mandatory for this script. This is our whole script, and these are the box we're working with. So here we need to move to. So let's put this on the outside. No. So. Let's go ahead and test this. Now if we move three, we need to only move two forward. So this block is not really necessary right now. Right now, we can use one of our own and replace that one later. So here we just type in two. We turn. Test this. And we will move to. Or there's a simpler way. It would use this. It would move, and then we would turn. We can put multiple blocks on the inside to make them do the same action as repeated. Sit one. Repeat blocks are necessarily a necessity or needed to complete multiple actions at once. Hopefully this taught you guys how to use the repeats and simple movement of the code dot org site next time we will be learning the sense blocks and how to control movement with those.