First Steps in Programming Raspberry Pi 3 Scratch Project

Published By

Raspberry Pi was designed to have an inexpensive Linux computer that people in education could afford and hence use to teach programming to any kid. Raspbian is the Linux OS by default, and Scratch is installed with this OS.

See related product

Raspberry Pi 3 Model B

Raspberry Pi Foundation Embedded System Development Boards and Kits View

What is Scratch Programming?

Scratch is a free visual programming language used to teach basic concepts of programming to beginners. There is no need to write lines of code to have an object move on the screen with interaction on behalf of the user. Young kids have created thousands of games with this language, and Scratch has shown many that programming is fun and is no longer reserved solely for specialists.

Raspberry Pi Scratch Projects: Your First Program

In this article, we create a program where the name “Arrow” moves on the screen following a hexagon.

In the Scratch language, objects are called sprites. We can create a new sprite thanks to the paint editor, although in fact, the Arrow logo image is imported.

Now, the script for this sprite can be designed. The program starts when the green flag is clicked. So, from the control window, the “when green flag check” puzzle piece is dragged to the script window. As we want to indefinitely repeat this program, we’ll have a big bracket “forever” wrap up all the functions we will use. Then we select “clear” to clear the window where the image pops up, and we wait for 1 second for the sprite to get to the position (0,0).

Next, we will wait for 1 more second, and the sprite moves to the position (0,100). As we want to draw the hexagon, the puzzle element “pen down” is selected. Then the program moves to the six vertices of the hexagon, with a waiting time of 1 second at each vertex. When the Arrow logo is back to the first vertex at the position (0,100), the hexagon is completely drawn, and we can add the “pen up” element. After, we’ll wait for one second to go back to the center, which is at position (0,0), and wait for one second again and the program can start again after the window is cleared.

This program uses only a few functions, but by their name, the task that is performed is obvious. The functions are split into eight groups as show in the matrix below.

Motion: moves sprites and changes angles

Looks: Controls the visuals of the sprite; attaches speech or thought bubble, changes of background, enlarges or shrinks

Sound: plays audio files and programmable sequences

Pen: Draws on portrait by controlling pen width, color and shade

Control: Conditional if-else statement, forever, repeat and stop

Sensing: Sprites can interact with the mouse, for instance

 

Operators: Mathematical operators, random number generator, and-or statement that compares sprite positions

Thanks to the user interface, it is easy to drag, drop and immediately visualize the effect of any change. Scratch allows users to have fun as they take their first steps in programming, and it build a good foundation for future programmers, one that will further develop in more advanced languages like Java or Python, for instance.

Related news articles

Latest News

Sorry, your filter selection returned no results.

We've updated our privacy policy. Please take a moment to review these changes. By clicking I Agree to Arrow Electronics Terms Of Use  and have read and understand the Privacy Policy and Cookie Policy.

Our website places cookies on your device to improve your experience and to improve our site. Read more about the cookies we use and how to disable them here. Cookies and tracking technologies may be used for marketing purposes.
By clicking “Accept”, you are consenting to placement of cookies on your device and to our use of tracking technologies. Click “Read More” below for more information and instructions on how to disable cookies and tracking technologies. While acceptance of cookies and tracking technologies is voluntary, disabling them may result in the website not working properly, and certain advertisements may be less relevant to you.
We respect your privacy. Read our privacy policy here