1st ESO: Technology, Programming and Robotics
Unit 5: Programming
Autor: Guillermo Gmez
Contents
Prior knowledge............................................................................................................ 2
Keywords...................................................................................................................... 2
Mindmap of the unit ..................................................................................................... 2
5.1.
Programming basics ......................................................................................... 3
5.2.
Example of IDE: Scratch.................................................................................. 4
5.2.1.
Introduction .................................................................................................. 4
5.2.2.
GUI (Interface) ............................................................................................. 4
5.2.3.
Example........................................................................................................ 5
5.3.
Programming apps for mobile devices: MIT App inventor ............................. 7
1st ESO
Unit 5: Programming
T.P.R.
Prior knowledge
Activity: Summarize your general knowledge on this topic.
Keywords
Activity: Copy following keywords, explaining their meaning and translate them into
Spanish.
Command
Flow diagram
IDE
compile
machine code
Bug
debug
Subroutine
Algorithm
GUI
duplicate
shrink
Variable
Backdrop
Sprite
Tab
Script
Event
Operator
Timer
Scoreboard
Random
Grid
Screenshot
Mindmap of the unit
Activity: Analize and try to understand following mindmap
CPU
T.P.R. 1st ESO.
Unit 5: Programming
Programming
languages
are
executed by
are written with
INSTRUCTIONS
consist of
PROGRAM
7.
is created in
a process:
1.PROBLEM
4.
programming
5.
compiling
6. Checking &
debugging
2.IDEA
these 3 stages are done in a
3.
flow diagram
Integrated Development Environment
e.g.
Scratch
Autor: Guillermo Gmez
MIT App inventor
1st ESO
Unit 5: Programming
T.P.R.
5.1. Programming basics
Program, languages and IDE:
A program is a collection of instructions that performs a specific task when executed
by the CPU of a computer. A part of a program that performs a well-defined task is
known as an algorithm; you may also find the names subroutine, procedure or
subprogram.
Programs are written in a programming language, which is human-readable. There are
different programming languages, each of them with their own commands
(vocabulary) and syntax (way of using commands).
The computer only can directly execute instructions written in a special language, the
machine code. The process of translating from a programming language into a
machine code is called compiling.
An Integrated Developmet Environment
(IDE) is a program that allows to:
1. program with a programming
language (human-readable form)
2. compile into machine code(computer-executable form)
3. run the program
4. save the program
1
Problem definition
IDE
4
Programming
2
Search of ideas
5
Compiling
3
Design (flow diagram)
Programming process:
1)Problem definition: Identify clearly the
needs.
2) Search for ideas: Choose the right
programming language and study the
needed algorithms (variables,
operations and formulas).
Flow diagram
Symbols
3) Design: Represent each
algorithm with a flow diagram
start / end
4) Programming (IDE): write the
program using the choosen
conector
language
5) Compiling (IDE).
Data
input /output
6) Checking and debugging
(IDE): run the program and if it
doesnt meet the needs (problem
decision
definition) fix the errors (bugs).
7) Saving and sharing (IDE).
process
6
Checking and debugging
yes
7
Saving and sharing
Example: Calculate your T.P.R. final mark
start
Read 4 marks:
N (notebook)
P (project)
C (computer)
E (exam)
Mean = N*0,2 + P*0,15 + C*0,15 + E*0,5
yes
E<3
no
Mean < 5
yes
no
Write: Mean
Write: failed
flow line
end
Autor: Guillermo Gmez
no
1st ESO
Unit 5: Programming
T.P.R.
Activity: Copy following exercises and solve them in your notebook
1) Explain what does the program designed in the flow diagram of page 3 do.
2) Design a flow diagram in which the user writes three califications and the
program calculates the mean.
3) Design a flow diagram in which the user choose two two-digit numbers and the
program adds them together.
4) Design a flow diagram in which the user writes two numbers and the program
shows the biggest one.
5.2. Example of IDE: Scratch
5.2.1. Introduction
Scratch is a new programming language based on a free IDE, that makes it easy to
create your own interactive stories, games, and animations and share your creations
with others on the web.
5.2.2. GUI (Interface)
The interface
consist of 4 bars:
title
menu
tool
screen mode
Title
bar
Menu
bar
Script Costumes
tab
tab
Sound
tab
Toolbar
Screen
mode
Stage
Start /
Stop
and 4 areas:
commands
tabs: scripts /
costumes /
sounds
stage
object panes
Depending on the
object selected on
the panes (sprites
or backdrops), the
corresponding
information will
appear on the
tabs.
Commands
Scripts
area
Stage
backdrops
Sprites
pane
Programming, checking and debugging
The program blocks (commands) are dragged into the script area. Their shape indicates
how they are assembled. When pressing the start button the action takes place in the
stage area, where you can check and decide if debugging is necessary.
Autor: Guillermo Gmez
1st ESO
Unit 5: Programming
T.P.R.
5.2.3. Example
1)Problem definition: Its about programming a game similar to the classic pacman:
using the arrow keys to move, you have to guide a scissors within a maze to reach a
rioter.
1.1)
1.2)
1.3)
The scissors moves forward as long it is in contact with the mazes path
Whenever you push an arrow key, the scissors points in the direction you push
When the scissors reaches a rioter, a new rioter appears in another part.
2) Search for ideas:
2.1)
2.2)
2.3)
Stage: Design or import a backdrop that you like and add a continuous music.
Sprites: a) scissors, b) the maze with the rioter
Subroutines: a) start the continuous music, b) to put the scissors in the starting
point and make it move if it is in contact with maze path, c) to rotate the scissors
with the keyboard, d) to change the rioters position if touched by the scissors
3) Design:
a: Music
b2: Scissor movement
start
start
play music
till end
Scissors
inside path
no
c: Scissor direction
yes
end
b1: Scissor appearance
start
move forward
a stretch
Read direction key
d: Rioter position
start
Show scissors
closed
Wait a time period
end
Autor: Guillermo Gmez
reached
by scissors
yes
point in direction
0, 90, 180, 270
Show scissors
open
Wait a time period
no
, ,,
end
no
yes
Show next position
end
1st ESO
4) Programming
(IDE):
Unit 5: Programming
T.P.R.
click to import the music
click to import the background
4.1)
4.2)
4.3)
Stage: Import
the
background
and the music,
and program it
to play
continuosly
(subroutine a)
click to program
Use the when green flag is
clicked event to make play the
music when the program starts
Use the control block forever to
create a loop (part of a program
that repeats itself continuosly)
Sprites:
Design two
costumes for
the scissors,
and at least
two costumes
of rioters
appearing in
different
positions of the maze
Subroutines
for the
sprites:
program
subroutine b
and c for the
scissors and
subroutine d
for the maze
with the
rioter.
Use the motion
blocks go to and
move to put the
scissors in the
starting point and
make it move if it
is in contact with
maze path
5) Compiling
(IDE).
6) Checking and
debugging (IDE):
Test, correct the
errors and check
that the program
meets the
requirements.
Use the motion
blocks point in
direction to
rotate the scissors
with the
keyboard
click to design
the different
costumes for
the sprites
Use the control block
forever if to change
the position of the
rioter (red color)
each time it is
touched by the
scissors (black color)
7) Saving and sharing (IDE). Dont forget to shave the final program and if you want
to share it you can do it through the IDE.
Autor: Guillermo Gmez
1st ESO
Unit 5: Programming
T.P.R.
Activity: Copy following exercises and solve them in your notebook
5) Program with Scratch the given example (Scissors rioter-game).
6) Improve the game: Design a new flow diagram for a subroutine in which the
stage will show the time on a timer and a scoreboard with the number of times
the scissors reaches the rioter. Improve the existing flow diagram so that it meets
this new requirement; additionaly each time the rioter is reached by the scissors,
he should shout through the speakers.
7) Add with Scratch the improvements designed in exercise 6.
8) Do the search-for-ideas step for following problem: programming a ping-pong
game with following features:
a. The program is designed for two players
b. It will have a scoreboard.
c. The game is over when one of the players gets four points.
d. Each time the racquet hits the ball, there should be a popping sound.
e. Once the game is finished the program declares the winner.
9) Design the flow diagrams for the ping-pong game.
10) Program with Scratch the ping-pong game.
5.3. Programming apps for mobile devices: MIT App inventor
App Inventor is a IDE for designing mobile apps for the Android operating system. It
was created by Google, but now the responsible for its support is the Massachusetts
Institute of Technology (MIT).
The programming is very similar to the one in Scratch. To get started, just follow the
instructions of the video: http://appinventor.mit.edu/explore/ai2/beginner-videos.html
As a student of second grade, you probably
have a mobile device,... but have you ever
heard about nomofobia? The term is an
abbreviation for no-mobile-phone phobia,
a term describing the fear of being without a
mobile device. Among todays high schools
its on the rise: more than two of three
students sleep with or next to their smart
phones!
NOMOFOBIA
Autor: Guillermo Gmez
Note
Although it is true that mobile devices make
life easier and enables us to work more
efficiently, dont forget that they should stay
always as servants, never as masters.
book
Using mobile devices you can get an
addiction that dictates your behavior!