Introduction For thousands of years people have created machines that could carry out tasks to help us In the 1700s inventors created automatons which were mechanical devices made to look like humans They were able to carry out a series of movements or play a basic tune on an instrument Relying on complex combinations of gears and levers these early robots were mainly used as a form of entertainment It wasn’t until the 1940s that electronics were used to control and program robots This led to the development of more sophisticated robots In this book we’ll look at how the different systems within robots work We will see how they move around sense where they are and interact with us You’ll use the algorithms and ideas that control real robots to create your own on-screen robots These programs will help you understand the world of robots and how they work There are a lot of different ways to create code We will be using a website called Scratch to do our coding Type scratch mit edu into your web browser then click Create to start a new project 4
Let’s start by looking at the important Let’s start by looking at the important parts of the screen in Scratch parts of the screen in Scratch File Menu for logged-in users If you want you can create an account for free and save your work online Check with a grown-up first Alternatively you can use the Load and Save options to open and save work on your computer Sound Library Add sounds to your program from here All Animals Effects Loops Notes Percussio New Save Now Save as a Copy Go to My Stuff New Load from your computer Upload to your computer Save to your computer Download to your computer Record and Export Video Revert File Menu for general users Choose Load and Save to open and save work on your computer File Edit Tutorials Code Costumes Sounds Motion move 10 steps turn 15 degrees turn 15 degrees Motion Looks Sound Events Control go to random position Sensing go to x 0 y 0 Operators glide 1 secs to random position Variables glide 1 secs to x 0 y 0 My Blocks point in direction 90 point towards mouse-pointer change x by 10 set x to 0 change y by 10 set y to 0 Block Categories Choose commands from these categories List of Commands Find the blocks you need by matching the color to the category name For example dark blue blocks will be found in the motion category Sprite Library Choose ready-made sprites for your programs Ballerina-c Ballerina-d Balloon1-a Bananas Baseball Basketball A Bass A Elec Bass A Elec Guitar A Elec Piano A Minor Uk A Piano A Sax A Trombone Scripts Area Add your commands or code here Sprite1 Sprite1 Stage Backdrops The Stage Your program takes place on the Stage Sprites Objects that move around in Scratch are called sprites Sprites Pane Use this area to select which of your sprites you want to add code or sound to Code Costumes Sounds costume3 Paint Editor This is where you can draw your own sprites or backdrops Costume Pane Drawing Tools 5
Following Instructions We’ll start off by looking at how a simple robot can be programmed to carry out a series of steps one after another This is called a sequential program If you don’t have a robot handy we’ll draw one and create a maze for it to travel through STEP 1 Remove the cat Spri duplicate delete export Right-click on the cat in the bottom right corner and click delete STEP 2 Add a sprite Hover over the Choose a Sprite button Click the Brush icon For help go to www maxw com 6
STEP 3 Start drawing Convert to Bitmap Click Convert to Bitmap Filled Outlined Select the Rectangle tool Set the rectangle to Filled Choose a color for your robot STEP 4 Draw the robot Start by dragging out a rectangle in the center of the drawing area Make it about one-quarter of the width of the drawing area We'll draw it quite large so we can add detail then shrink it in step 11 Click off the rectangle and then select a darker color Create two more rectangles to be the robot’s arms Click the Undo tool if you make a mistake STEP 5 Eyes and details Choose white then draw two white rectangles to start creating the eyes Select black then add pupils to the eyes Add any other details you want to your robot 7