bug session two. session description in this session the use of algorithms is reinforced to help...

6
Bug Session Two

Upload: dorcas-mckenzie

Post on 20-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their

Bug

Session Two

Page 2: Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their

Session description

In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their Bug. They are introduced to the idea of a variable and discover how variables can be used in a program.

Objectives

The students will:

• Use an algorithm to plan a sequence• Use an algorithm to plan a sequence using a variable• Use a variable in a program• Use variables to create patterns• Debug any errors in their program

Session activities summary

• Reinforce use of an algorithm to be implemented as a program

• Discover how a variable can be used to make lines on a Bug

Resources

Bug website Bug software

BugBug cables

Bug: Session Two 1

Page 3: Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their

Bug: Session Two

ActivitiesPlanning an algorithm

What is an algorithm? (check understanding from previous session)

A set of instructions to achieve a set objective. Make sure pupils understand it is 'planning' what will happen and that

the coding or programming is actually 'making it' happen.

Can you write the algorithm to turn an LED on and off?Accept any way of recording this; numbered instructions, a flow chart or other way of recording. Make sure pupils are not actually describing the blocks they used but arelisting the sequence of what happens.

In lesson 1 we have seen that using a repeat block makes our programming easier. We are now going to find a way to light up a whole row without having to program each LED light individually.

What does variable mean? - something that changes.

A lot of games keep a 'score' to show you how well you are doing. 'Score' is a variable.When you have a spelling test what happens each time you spell a word correctly?- Your score goes up by one- Show score as a box- I’ve got another spelling right what happens to my score?- Add one to the score (repeat as necessary).

Write this as an algorithm.

Time5 minutes

5 minutes

2

Spelling test algorithm• Set score to 0• Repeat for the number of words in the test• Listen to spelling• Write spelling

• If spelling is correct add 1 to score

Did you know?

There is a Bitesize computing guide called: What is an algorithm?

http://www.bbc.co.uk/guides/ z3whpv4#orb-banner

Page 4: Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their

Bug: Session Two

We are going to use a variable to make any LED in a row light up.Teacher demonstrates using set item block (Click on Variables to see these blocks).

5 minutes

3

Use drop down menu next to item to rename it as 'x'. Our variable that will change is the 'x'.

What happens when I run this bit of program?

What happens when I change the value of x? – show changing it to any number between 1 and 4.

Ask the children to create a variable for ' x' and see if they can change it.

Can they find out how to set a variable for y and change it?

10 minutes

Drag both the 'set item' and 'item' blocks from the Variable menu to the script area together with the ‘plot’ block from the LED menu. Drag the ‘0’ value block from the Basic menu to put in set item block.

Page 5: Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their

Bug: Session Two

We can get our Bug to change the variable itself by counting. As it counts the x variable from 0 to 4 this will light up each LED moving across the row.

Show pupils ‘count with’ block under Loop menu. We have already used the repeat loop. This is a special kind of repeat loop.

Challenge: Can you use these blocks to get the top row of LEDs to light up?

It is counting from 0 to 4 going up in 1s. Each time the count is increased by 1 it repeats the loop but changes the value of the variable.

What variable do we need to change? The value of the 'x' coordinate.

Note: Pupils will need to rename item to be 'x'. They can set the 'x' value to '0' – as they did earlier in the lesson.

Encourage pupils to keep testing what they have done to see if it works. Provide guidance as needed.

10 minutes

10 minutes

4

Page 6: Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their

Bug: Session Two

15 minutes

5 minutes

5

.

Download your pattern to your Bug.

What do you need to do to make different columns light up? You will need to make a variable for 'y' and change the value of 'y'.

What patterns can you create on your Bug?

Pupils will be able to rename the variable 'x' to change it to 'y'. If they want to have rows and columns drawn in the same pattern, they will need to add a new variable. Go to Variables. Get a ‘set item’ block and choose new variable from the drop down menu.

Encourage pupils to look at each others’ patterns and ask for help from their peers.

See session one.