First Steps in Programming Raspberry Pi 3 Scratch Project

게시자

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.

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.

최신 뉴스

Sorry, your filter selection returned no results.

개인정보 보호정책이 업데이트되었습니다. 잠시 시간을 내어 변경사항을 검토하시기 바랍니다. 동의를 클릭하면 Arrow Electronics 개인정보 보호정책 및 이용 조건에 동의하는 것입니다.

당사의 웹사이트에서는 사용자의 경험 향상과 사이트 개선을 위해 사용자의 기기에 쿠키를 저장합니다. 당사에서 사용하는 쿠키 및 쿠키 비활성화 방법에 대해 자세히 알아보십시오. 쿠키와 추적 기술은 마케팅 목적으로 사용될 수 있습니다. '동의'를 클릭하면 기기에 쿠키를 배치하고 추적 기술을 사용하는 데 동의하는 것입니다. 쿠키 및 추적 기술을 해제하는 방법에 대한 자세한 내용과 지침을 알아보려면 아래의 '자세히 알아보기'를 클릭하십시오. 쿠키 및 추적 기술 수락은 사용자의 자발적 선택이지만, 웹사이트가 제대로 작동하지 않을 수 있으며 사용자와 관련이 적은 광고가 표시될 수 있습니다. Arrow는 사용자의 개인정보를 존중합니다. 여기에서 당사의 개인정보 보호정책을 읽을 수 있습니다.