Lesson video

In progress...

Loading...

Hello, everybody.

Welcome to Computing.

My name is Mrs. Franzsen and it's really great to have you in my lesson today.

Let's get started in learning about physical computing.

By the end of this lesson, you'll be able to design a physical project that includes selection.

Let's look at our keywords for today.

Let's look at our first keyword, repetition.

Repetition is a part of a programme where one or more commands are run multiple times in a loop.

The second key word is condition.

A condition is a statement that can either be true or false, and you can see when we use the words true or false to talk about conditions, then we use a capital T for true and a capital F for false.

The next key word is selection.

Selection is a part of a programme where if a condition is met, then a set of commands is run.

In the first part of the lesson, you are going to describe selection in automated systems. A Crumble microcontroller can be used to control various inputs and outputs.

In this diagram, I have labelled the Crumble, the Sparkle, and the push button switch.

We've got two programmes here.

Which programme controls more than one output device? Is it programme one or two or both? Have a think about that.

You can pause the video while you do so.

Programme one controls one output device, a Sparkle LED.

Programme two controls a motor and a Sparkle LED.

Programme two uses two output devices.

Let's do a check here, which device is an example of an output device? A, microphone, B, LED light, C, mouse, or D, battery pack? Pause the video here to think about your answer.

Welcome back.

The answer is B.

An LED Light is an example of an output device.

Well done if you got that one right.

Repetition is a part of a programme where one or more commands are run multiple times in a loop.

Account controlled loop uses a number as a condition.

Let's look at these two programmes again.

Which programmes use account controlled loop? Is it programme one or programme two or both? Pause the video To have a think about that.

Programme one uses a forever loop and if-then loop and account controlled loop.

Programme two only uses one loop and if-then selection loop.

So the answer here is that programme one uses account controlled loop.

Well done.

If you spotted that selection is represented by this command block, which is a loop.

If the condition is true, then the actions within the block will happen.

Let's do a check here.

Which programme uses selection? Is it programme one, programme two, or both? Pause the video to have a think about that.

Welcome back.

Both programmes use selection.

You can see that they're both using an if then loop.

Well done if you got that one right.

In programmes, you need to instruct the device to repeatedly check if the condition has been met.

Otherwise, it will only check once when the programme is run.

By adding an infinite loop, that's a forever loop, you can repeatedly check if the condition has been met.

In Crumble the loop looks like this.

It's a do-forever loop.

Let's look at these two programmes.

Which programmes use a loop to continuously check if a condition has been met? Is it programme one or programme two or both? You can pause the video here to have a think about that.

Programme one has an infinite loop to continuously check if the condition has been met.

This is a house of the future where lots of tasks are controlled by devices.

The devices are programmed to carry out actions when a condition has been met.

This is selection.

An example of this would be the lights in this house.

The lights go on automatically when it gets dark.

In what ways might selection be used by devices in the house? Pause the video and have a think about that now.

Laura says, "It could have taps that turn on when you put your hands under them." Izzy says, "What about a door that opens when someone gets close to it?" Jacob says, "Blinds that open when it is light outside." Here is an algorithm for turning on the lights.

Forever if it is dark, then turn on the lights.

The condition is if it is dark.

The action is turn on the lights.

Why has forever been used? Pause the video here and think about that question.

The device needs to repeatedly check if the condition has been met.

This is repetition.

Okay, now you're gonna get ready for a task here.

I want you to use the if-then structure to write three algorithms to show how selection and repetition might be used in an automated house.

Remember to identify the condition and the action.

Here are some ideas: curtains or blinds, heating or cooling, taps.

You can pause the video here to go and work on your selection task, and when you come back I can show you some examples.

Welcome back.

Well done for all of your hard work on that task.

Let's go through some example algorithms here.

This is the algorithm for automatic taps.

It says forever if motion is sensed under the taps, then turn on the water.

This is the algorithm for automated curtains.

It says forever if it is light outside, then pull back the curtains.

And this one is for cooling system.

It says forever if temperature reaches 25 degrees Celsius, then turn on the air conditioning.

Remember, for these algorithms, it's a really good idea to put that indentation in where you make sure that the lines move away slightly from the margin each time to show how the different commands are linked.

In the next part of the task, you are going to design a hardware system for selection programmes.

Look closely at this image of a fairground ride.

It is a carousel.

Sometimes these rides are called swing rides or chair planes.

In this lesson, you'll be designing a carousel ride that will be controlled by a Crumble microcontroller.

This example shows a model carousel controlled by a Crumble microcontroller.

The Crumble is controlling the motor, which makes the model move.

Your task is to design a carousel model that uses at least two different output devices.

How could you use selection to do this? Pause the video and have a think about that.

Here are some ideas.

Jacob says, "If the button is pressed, set the motor power to 100%.

Sam says, "If the motor has started, then flash the sparkle light yellow and red." And Izzy says, "If the motor is off, then turn the light purple." You might have had some similar ideas or something quite different from that and that's great.

In a carousel programme, the components are programmed to carry out the actions When a condition has been met.

This is selection again.

An example would be forever If the push button switch is on, then set the motor forward at 100% power.

Let's do a check here.

Selection is only used for turning things on and off.

Pause the video to think about your answer.

The answer is false.

Why? Selection can be used for different actions such as changing speed or colour.

Well done if you got that one right.

In the first part of the task, you'll design your model.

A label diagram of your project will help you decide on the different parts of your design.

You should also identify the input and output components that you will use.

When you design your carousel, think about your ideas for using selection.

You will need to make sure your design has the correct components to work.

Laura said, "I want to use two sparkles in my carousel, so I will include them in my design." In the second part of the task, you will draw a labelled wiring diagram.

Sam says, "This is to show how your Crumble will be connected to its components." Looking closely at the Crumble, the holes in the Crumble are the pads.

The pads are the connection points between the Crumble and the components.

Looking closely at the sparkle, you can see that the pads connect to positive power pads, negative power pads and the D pad on the Crumble controller.

This is all on the left hand side.

And the pads on the right hand side are used to connect to other sparkles if you are adding them on in a chain.

The motor should be connected to the positive and negative motor pads next to the number one on the Crumble.

The number one is the motor number, because you can connect two motors to a Crumble.

The push button switch connects to the Crumble like this.

Let's do a check here.

Which component is an input device? Is it the push button switch, the battery pack, the Sparkle LED, or the motor? Pause the video here to Think about your answer.

Welcome back.

Good effort on thinking about the answer there.

The answer was A, the push button switch is the input device.

Okay, let's get ready for the task.

The first part is drawing the label diagram of your carousel project.

This is where you are going to draw your sketch.

Make sure you add the components that you're going to use.

It's time to go and work on your label diagram of your carousel project.

Pause the video here and when you come back, I can show you an example.

Welcome back, Well done for your hard work on that part of the task.

This is an example of a labelled diagram of a carousel project.

You can see we've got some rough idea of measurements here of the model that's going to be built, how wide the disc is going to need to be at the top, and we've also labelled all of the different components that we're going to use.

The technology devices and the different modelling pieces as well like string and card.

For the second part of this task, I want you to complete the wiring diagram to show how your Crumble will be connected to its components.

So we've already given you a pre started diagram with the Crumble and the battery pack and your job is to complete this, adding in all the components that you're going to use and showing them how they are going to connect.

Pause the video here to work on this part of the task and when you come back I'll show you an example.

Welcome back.

Well done for working on your wiring diagram.

Here is an example of that.

You can see that we've drawn in the Sparkle on the right hand side, as well as where it connects to on the pads.

We've added our push button switch and we've added our motor in as well.

You have worked really hard in your lesson today.

Excellent effort.

Let's summarise our learning about designing physical projects that include selection.

In algorithms and programming, selection allows a programme to carry out specific actions when a condition is met.

The if-then structure is used to structure these decisions.

To keep checking whether a condition has been met repetition is used.

When designing a physical project with inputs and outputs, a wiring diagram is needed.

This is in order to show how the different components will connect together.

Thank you for joining me in this lesson today and I hope to see you again soon.