Raspberry_Pi_Education_Manual

Notes:

Over to you

Question: Study the code shown above for the cat sprite and the stage. Do you understand it? Task: Experiment with the code. See if you can add some extra questions.

A final word

In fact, the cat is not intelligent at all. Computers have no intelligence – it is the programs that run on them that make them appear intelligent. This is why we use the term “artificial intelligence”. The only intelligent things here are the programmer, who programmed the cat, and you, for completing Lesson 1.5.

Lesson 1.6: Control

Learning objective: In this exercise, you will learn how to write control programs that respond in different ways depending on inputs to the program. Resources: The sprite “ robot_up ” and the background “ green_background ”.

The robot

This is how we think of robots, but most robots don’t look like this.

You’re probably used to robots from the movies: metal men clanking and talking in metallic voices. This is actually an old-fashioned idea of a robot. It dates from a play written in 1920. I bet even your teacher was young then. A more modern way of thinking about a robot is as anything that can be controlled by a computer. This is known as “control engineering”. This device could be an aeroplane, a washing machine, a lathe, a welding machine, a level-crossing barrier, a sewing machine, a self-drive car or anything else you can imagine. But let’s start with a proper, old-fashioned robot. We don’t have a real robot, or all the wires and circuits we’d need to control one. So, instead, we’ll use a robot that lives inside the Scratch stage. What you learn by doing this is how to make your robot respond to inputs. We are going to program our robot so that we can control it using the “up arrow” key. To make it easier to see our robot moving, we need to be able to see him from above.

Import the sprite “ robot_up ” from RPiScratch/Resources/Costumes. While we’re at it, import the background “ green_background ” from RPiScratch/Resources/Backgrounds.

A beginner’s guide to Scratch

35

Made with FlippingBook flipbook maker