How to Learn to Program From Scratch Using Scratch!

by Nmoleo­ in Circuits > Computers

996 Views, 17 Favorites, 0 Comments

How to Learn to Program From Scratch Using Scratch!

temp2.png

Hello, my name is Nicholas Anand and I am 13 years old. When I am old enough, I want to start a software company and sell my software. I'm not quite good enough yet at programming to make something that people want to pay for, but I do understand the basics and I want to teach them to you.

Programming is great because you can design something, anything. You can make your computer do whatever you want, and it's not even very hard!

I am going to show you the very basics of programming using a language called Scratch, which is an online drag-and-drop programming language designed to teach you how to program.

I hope you enjoy my tutorial and learn something from it!

:D

The Fundamentals of Programming

Before you program anything, I want to tell you about what programming is and how it works. You don't have to read this step if you just want to make something, but I highly recommend that you do.

Computers are designed to follow a series of steps that the user assigns it to do. A good example is when you talk to Siri, Cortana, or Google Now on your phone. You might say, "Call John Doe", and your phone would call up John Doe. Programming is very similar to talking to your phone's personal assistant. You tell the program to follow a series of steps and it does it.

A more 'programmy' example is where I might tell the computer, "Every time I get an e-mail, open up my database file and log in the date, time, and user that sent me the e-mail".

Now, let's actually program something!

Sign Up for Scratch

temp1.png

The language I will be teaching you is called Scratch. It is designed to teach you how to program without throwing you off the high dive. Instead of typing lines of code, you drag and drop blocks together. Let's create an account.

First of all, go to http://scratch.mit.edu. The homepage should pop up. In the top right-hand corner, click the link that says "Join Scratch".

A window will pop up asking for you to type in a username and password. Fill out the boxes.

On the next step, it will ask you for your age, gender, and country. Don't worry - Scratch won't put any of that information on your profile page. It's just so the Scratch team knows who is using their software.

On the next step, Scratch will ask you for your e-mail address. Type it in and your account setup is complete! Click the button that says "OK Lets Go!".

Make sure to check your e-mail and click the confirmation link.

Your First Steps in the Scratch IDE

temp3.png

You are now a member of Scratch! Feel free to explore and play around with what you have in front of you for a little while before I tell you how to make your first project.

Once you're ready to start, click the link that says "Create" in the menu at the top of the webpage. Scratch will open up the editor for you and you're all ready to go.

Now, once you're inside the editor, it might seem very complicated with all kinds of buttons and things you can do. But don't worry, you'll get the hang of it soon enough.

See the picture above. I have added the names of each section to make it less complicated in the future.

When you start, the blocks section should be in the 'motion' category. Take the block that says "move 10 steps" and drag it into the code area. Once it's in the code area, click on it once. The cat moves! What you are doing when you click the block is saying "Hey Mr. Cat, move 10 steps forward!".

Use the Green Flag

temp4.png

Now that you made the cat move, let's make it move when you click the green flag. The green flag is like a "go" button. It is the button generally used to start your program.

In the Block Categories section of the editor, find the section called "Events" and click on it. When you click it, all the blocks should change to "event" blocks. Find the block that says "when [green flag] clicked". Drag it above your "move 10 steps" block and get them to connect.

Right above the stage, there should be a green flag and a red stop sign. Click on the green flag. If you did it correctly, your cat should move.

Making a Loop

This is really cool, but do you want to have to keep clicking? The whole purpose of computers is to make stuff easier! Let's use a loop to fix this problem.

Find the "Control" category of blocks. One of the blocks should look like a C, and should say "forever". Drag it into the code area and put it in between the "when green flag clicked" and "move 10 steps" blocks. Click the green flag. The cat should move until it gets to the end.

Click the stop sign and drag the cat over to the left side. Click the flag again, and the cat should move again.

For extra credit, try and make the cat move backwards!

Trampolines!

The cat keeps getting stuck at the edge. How about we make the computer fix the problem for us! Find the block that says "if on edge, bounce" in the Motion category and put it after the "move 10 steps" block.

What this block does is it detects if the cat is touching the edge. If it is, it turns the cat around.

Try out your program now. The cat should start bouncing back and forth between the two walls.

It's Over! (For Now)

NOTE: I will keep updating the tutorial; it's not finished yet!

You have reached the end of my tutorial! However, this doesn't have to be the end of programming for you! Try out other stuff in Scratch, and try out other languages too!

I hope you learned something from this tutorial.

Have a nice day!