Sie sind auf Seite 1von 4

Using the brick’s built-in programming functions to construct an alarm device

This task is intended for use with an Area Secondary class

Introduction: 15 min.
The job of every programmer is to:
1. Analyse the requirements of a problem
2. Create specifications/requirements – stressing on inputs/outputs
3. target for a solution

How does a programmer design a solution to a problem?


Through the use of Flowcharts – also called Data Flow Diagrams.

Copy the following symbols from the whiteboard:

terminal process Input /


Decision
Output

Connector Flow of control (arrow)

The class is split into groups of 3 or 4 students (depending on class population)

Task part 1:
Use the brick to generate a Tone 8 min.

Program requirements
The brick is programmed to emit a beep.

Learning outcomes:
• Students learn how to draw a flowchart and understand how it works by putting it
immediately into practice.
• Students will familiarise with the brick’s onboard screen, interface and programming
features

Group Exercise: Start


Put the following four steps in order and use a flowchart to represent
the program and run it:
Generate
Tone 1
Stop Output Tone to speaker Start Generate Tone 1

o Correcting the flowchart


Output Tone
to speaker

Stop
Use the brick’s inbuilt functions to convert the flowchart into a working program:

Tone1 Empty(X3) Stop

Task part 2:

Use the brick to generate a siren Tone 10 min.

Program requirements:
Building on the program of Task 1, add the necessary steps so that
the brick will emit a siren tone. Start

Learning outcomes:
• As per Task part 1 continued
• Students will understand the concept of a ‘loop’ in a program Generate
and putting it into practice. Tone 1

Output
Group Exercise: Sound
Put the following steps in order and use 6 flowchart symbols to draw
them in a flowchart:
Generate
Generate Generate Output Tone 2
Tone 2 Tone 1 Tone 1
Output Start Connector
Tone 2 Output
Sound
o Correcting the flowcharts.

Use the brick’s inbuilt functions to convert the flowchart into a working program and run it:
Task part 3:
Use the ultrasonic sensor to activate an alarm when something/someone moves
near 20 min.

Program Requirements:
Alarm beeps when activated, waits for ultrasonic sensor to Start
detect intruder.

Learning outcomes:
• Practise of skills learnt in previous tasks Generate
• Learning the concept of a ‘decision’ in flowchart Tone 1

terminology.
Output
Group Exercise: Sound

Since this flowchart is a bit more complex, students are given an


incomplete flowchart (data flow lines and connectors only) to fill
in. Ultrasonic
input
Generate Generate Output
Tone 2 Tone 1 Tone 1
Output Start Connector
Tone 2 Detected n
Detected intruder
intruder y

Generate
Correcting the flowchart. Tone 2

Explanation:
the small loop is an example of Repeat Until in Output
Sound
programming.

Use the brick’s inbuilt functions to convert the flowchart into a


working program:

Tone1, motion, Tone2, empty, loop


Task Part 4

Assembled robot moves back and forth between two obstacles 25 min.

Program Requirements:
The robot needs to reverse until it hits something, move Start
forward until it senses something (object), then continue
moving back and forth between two obstacles (loop the
above).
Reverse
Learning outcomes:
• Learn how to draw a flowchart with less help
provided
• Practice the skills learnt in previous tasks Touch
Sensor
input
Exercise:

Students draw a flowchart to design a program that meets


the program requirements. Each student has to try to draw Hit
the flowchart by him/herself before joining the group to something
? n
work with the robot.
y
o Correcting the flowchart.

Move forward
Converting the flowchart into a working program:

Ultrasonic
Sensor
input

y Hit
something
?

Conclusion: 7 min.
What is the flowchart symbol for Start / Stop?
What is the flowchart symbol for Input / Output?
What is the flowchart symbol for a process?
What is the flowchart symbol for Decision?
How many inputs does a decision have?
How many outputs does a decision have?
What do we use to connect two flow of control lines (arrow lines)?
What is a repeated sequence in a program called?

Das könnte Ihnen auch gefallen