Lesson video

In progress...

Loading...

Hello, my name is Mrs. Holborow, and I'm so pleased you've decided to join me for the lesson today.

In today's lesson, we're going to be looking at what we mean by physical computing, and we're going to be creating our own working circuit using a microcontroller.

Welcome to today's lesson from the unit, "Using physical computing to create a robot buggy." This lesson is called, "Introduction to Physical Computing", and by the end of today's lesson, you'll be able to describe physical computing and create a working circuit.

Shall we make a start? We will be exploring lots of keywords in today's lesson.

Let's take a look at them now.

Physical computing.

Physical computing, "using code and electronic components to interact with the physical world." Microcontroller.

Microcontroller, "a small computer on a single chip that is designed to control simple devices and systems." Embedded systems. Embedded systems, "a computer built into a device to perform one specific task or a small set of tasks." GPIO pins.

GPIO pins, "connection points on a microcontroller that you can programme to send or receive signals." Look out for these key words throughout today's lesson.

Today's lesson is split into three sections.

We'll start by describing physical computing.

We'll then move on to set up and test a microcontroller.

And then finally, we'll create a working circuit using a microcontroller.

Let's make a start by describing physical computing.

A microcontroller unit or MCU, is a single integrated circuit.

They are small, self-contained computers that are designed to perform specific tasks in embedded systems. An embedded system is a piece of hardware or product, that has a built-in computing system.

Microwaves, washing machines, drones, and digital thermometers are all examples of embedded systems. MCUs have programmable inputs and outputs, built-in memory and a processor.

MCUs are flexible and can be set up in a variety of ways to solve real life problems. Inputs let the microcontroller receive information from the real physical world.

Components such as buttons and sensors can be connected to inputs.

Outputs let the microcontroller control things that are connected to the outside physical world.

Microcontrollers send signals to components such as LEDs, motors, and buzzers to tell them what to do.

The built-in memory helps the microcontrollers store code and data, making it work without needing a hard drive or external storage.

This keeps the microcontroller compact and energy efficient.

The processor in a microcontroller executes the instructions in your code.

It reads input signals, makes decisions based on your programme and sends signals to outputs.

It runs these instructions very quickly and continuously.

Time to check your understanding.

I have a question for you.

Input pins on a microcontroller, A, control things that are connected to the real physical world, B, receive information from the real physical world, or C, execute instructions in the code.

Pause the video whilst you think carefully about your answer.

Did you select B? Well done.

Input pins on a microcontroller, receive information from the real physical world.

Microcontrollers are used almost everywhere in modern life, especially in everyday devices that need to sense, control, or react to their environment.

Alex says, "Microcontrollers are found in products around the house, such as washing machines, microwaves, game controllers, and security systems." You're right Alex, they're some really good examples.

Well done.

Sofia says, "Microcontrollers are found in many types of healthcare devices, such as insulin pumps, heart rate monitors, and imaging machines." Again, some really good examples there from Sofia.

Izzy says, "Microcontrollers are used in pretty much all types of transport, including trains, cars, planes and boats!" Well done Izzy, that's some really good examples.

Jun says, "Microcontrollers are used in industry and robotics to control factory automation, drones, and environmental monitoring systems." Can you think of any other examples of where microcontrollers may be used? Maybe pause the video whilst you have a think.

The Raspberry Pi Pico is a low-cost, high performance microcontroller board.

The word Pico is Spanish for small, and that's probably quite appropriate because look just how big the PICO is.

It's really tiny.

The Pico contains 26 multifunctional general-purpose, input and output or GPIO pins.

You can connect things up to the GPIO pins using jumper cables, which are wires, and programme them to do something.

For example, you could programme the Pico to turn on an LED, a light emitting diode, on and off.

So here's an LED, and we could programme the Pico to turn this LED on and off.

Izzy has a question.

Izzy says, "what is physical computing?" Do you know the answer to this question? Maybe pause the video whilst you have a think.

Physical Computing is when you connect physical objects like motors, LEDs, and sensors, to a computer and use code to control them to interact with the physical world.

Izzy says, "Physical computing sounds fun!" I think you're right, Izzy.

There's all sorts of projects we can do.

Sofia says, "Physical computing is fun because you get to see your code coming to life in the real world.

You get to make lights blink, and motors move, or by writing your own programmes.

You can even make buggies!" Time to check your understanding.

I have a question for you.

In a microcontroller, what executes the instructions in your code? Is it A, the processor, B, memory, or C, GPIO pins? Pause the video whilst you have a think.

Did you select A, the processor? Well done.

True or false? Microcontrollers have built in memory.

Pause here whilst you think about the answer.

Did you select true? Well done.

Microcontrollers have built-in memory, so they can store and remember the instructions in your code.

What does GPIO stand for? Pause the video whilst you think about your answer.

Did you say, General-purpose Input and Output? Well done.

Okay, we are moving on to our first task of today's lesson, Task A.

For part one, I'd like you to write two to three sentences to describe physical computing.

And then for part two, I'd like you to describe two applications, where microcontrollers are used in everyday products.

Remember, if you need to go back to previous slides in the deck, you can pause the video and do that now.

How did you get on with task A? I'm sure you did a fantastic job.

Let's have a look at some sample answers together.

So for part one, you were asked to write two to three sentences to describe physical computing.

Physical computing is when physical components like motors, LEDs, and sensors, are connected to a computer or microcontroller.

These components are controlled using code to interact with the real world.

It allows you to create interactive devices that respond to inputs, and can help solve real world problems. For part two, you are asked to describe two applications where microcontrollers are used in everyday products.

Microcontrollers are used in everyday home appliances, such as washing machines and microwaves.

Microcontrollers are also used in medical devices such as image scanners and heart rate monitors.

Microcontrollers can be used in different applications, because they are flexible, and can be programmed and set up in a variety of ways.

Did you have some similar applications, or did you have something different? Okay, so we've described what we mean by physical computing.

Let's now move on to set up and test a microcontroller.

The first stage of this physical computing project, is to set up the Raspberry Pi Pico, by connecting it to a computer, installing the necessary software, and writing a basic programme to test that it works.

For this project you're going to need a Raspberry Pi Pico microcontroller, a breadboard, and a micro USB cable.

So, here's the micro USB cable, here's the breadboard, and here's the Raspberry Pi Pico.

Microcontrollers such as the Raspberry Pi Pico may have header pins that let you easily connect the microcontroller to a breadboard.

So you can see here the header pins are labelled on the diagram.

And if you look carefully, you can see here that my Pico has the headpins already attached.

Header pins can be easy to bend by accident.

Care should be taken to line them up with the holes on the breadboard.

First, place your Raspberry Pi Pico on a breadboard, so that the two headers are separated by the ravine in the middle of the breadboard.

So you can see the ravine is indicated by a shaded grey panel in the middle of the board.

Then plug your micro USB cable into the port on the left-hand side of the board.

So, you can see here on my Pico, where the micro USB cable is connected into.

Carefully push the Pico down into the breadboard, taking care not to use too much force.

Your Pico should now be laying flat against the breadboard.

To programme the Raspberry Pi Pico, you'll need a piece of software called Thonny.

Thonny is available for Windows, Mac Operating System, and Linux, and comes pre-installed in Raspberry Pi OS.

The next step is to connect your Raspberry Pi Pico, and add the MicroPython firmware.

on the Raspberry Pi Pico, press the BOOTSEL button, and hold it while you connect the other end of the micro USB to your computer.

So the BOOTSEL button is indicated here on the diagram.

On my Pico, you can see it here.

It's this very small white button, and it actually says BOOTSEL printed on the board underneath it.

This puts the Raspberry Pi Pico into USB mass storage device mode.

In the bottom right hand corner of the Thonny window, you will see the version of Python that you are currently using.

So in this example, we are using Python 3.

7.

3.

Click on the Python version in the bottom right hand corner of the Thonny window and choose MicroPython Raspberry Pi Pico.

A dialogue box will pop up to instal the latest version of the MicroPython firmware.

The popup box will look something similar to like I've got on the slide below.

Click the instal button to copy the firmware to your Pico.

Wait for the installation to complete and then click Close.

You don't need to update the firmware every time you use your Raspberry Pi Pico.

Next time, you can just plug it into your computer without pressing the BOOTSEL button.

Now, you can use the Thonny shell to run some simple python code on the Raspberry Pi Pico, and this will test that we've got it working correctly.

Make sure that your Pico is connected to your computer and you've selected the MicroPython Raspberry Pi Pico interpreter.

Look at the shell panel at the bottom of the Thonny editor.

You should see something like this.

So you can see it says MicroPython, and then we've got a version number, and then it says Raspberry Pi Pico with 2040.

And at the bottom of the Thonny window, it no longer says Python, it says MicroPython Raspberry Pi Pico.

Thonny is now able to communicate with the Raspberry Pi Pico.

Type the following command directly into the shell, press enter, and it will run on your Raspberry Pi Pico.

So you can see here we've said print, and then we've got the word hello, surrounded by brackets and speech marks.

And here's an example of it in the Thonny shell.

Time to check your understanding.

In which corner of the Thonny window can you click to set the version of Python? Is it A, the top right, B, the bottom left, or C, the bottom right.

Pause the video, whilst you think about your answer.

If you selected C, the bottom right corner, you'd be correct.

Well done.

I've got a true or false statement now for you.

The BOOTSEL button must be pressed every time you connect the Raspberry Pi Pico to a computer.

Is this statement true or false? Pause the video whilst you have a think.

Did you select false? Well done.

It's false, because pressing the BOOTSEL button puts the Raspberry Pi Pico into USB mass storage device mode to enable firmware instals and updates.

There is no need to press the button each time the Pico is connected to a computer.

You just need to do it once when you start setting up your Pico.

This diagram shows the position of the Pico's GPIO pins.

General-Purpose Input and Output pins allow you to connect input and output devices to a Raspberry Pi Pico, and obtain or send signals between them.

Note at the top of this diagram, the onboard LED is taking up GP25.

Therefore, to turn that on, you need to send a signal to that specific pin.

MicroPython adds hardware specific modules, such as machine, that you can use to programme the Raspberry Pi Pico.

If you set the value of a pin object to 1, it turns it on.

If you set the value of a pin object to 0, it turns it off.

Similarly, you can use, pin_variable.

low() for off and, pin_variable.

high() for on To turn the Pico's onboard LED, you can use the following code.

So, from machine import pin, led = Pin notice the capital P, (25, Pin.

OUT) close the bracket.

led.

value(1) in brackets.

So remember 1, represents on.

Save your file, you can save it to your computer or Pico, and then click Run.

You should then hopefully see, that the built-in LED on the Pico turns on.

Oh, Alex has hit a problem.

Alex says, "Something's not right, my code doesn't work.

Let's have a look at Alex's code.

So Alex has got, From machine import PIN led = PIN(25, Pin.

OUT) and then, led.

value(1) Can you spot the error, or why Alex's code is not working? Maybe pause the video whilst you have a think.

Ah, Izzy spotted it.

"MicroPython is similar to Python, but it's designed to run on microcontrollers like the Raspberry Pi Pico.

I think they're both case sensitive." Python and MicroPython are both case sensitive programming languages.

For example, the character uppercase P, is treated as a separate character, to the character lowercase P.

This means pin, Pin, and PIN, are all different names because they're using different cases.

If you use the wrong capitalization, your code won't work, and may cause an error.

Alex says, "I didn't realise MicroPython was case sensitive.

I think I've spotted the errors in my code." So, we've got a capital F, we've got capitals for the whole of the word PIN, and again we've repeated that there.

So, Alex has fixed his code.

He says, "That was an easy fix and my code now works!" And we can see the LED is switched on, on the microcontroller.

Well done Alex.

You can turn the LED off, by changing the LED.

value(1) to LED.

value(0) and running the programme again.

So let's have a look at the code.

Line one's exactly the same.

So, from machine import Pin led = Pin(25, Pin.

OUT) So remember it's Pin 25 that we are using for the built-in LED, but line three is different this time, because we have led.

value(0) instead of 1.

Save your file and then click Run.

The LED should now have turned off.

Time to check your understanding.

Which GPIO pin is used to control the Pico's onboard LED? Is it A, 25, B, 15, or C, 22? Pause The video whilst you have a think.

Did you select A, 25? Well done.

Okay, we are moving on to our second task of today's lesson, Task B.

For part one, if you can, follow the Task B activity 1 instructions which are provided as an additional resource for this lesson to set up a Raspberry Pi Pico and control the onboard LED.

For part two, describe how you found the process of setting up and controlling the onboard LED.

For example, did you find it tricky, or was it straightforward? Pause the video here whilst you complete the tasks.

How did you get on? Did you manage to set up the Raspberry Pi Pico, and control the onboard LED? I hope you did, because it would be really fun if you can.

For part two, you were asked to describe how you found the process of setting up and controlling the onboard LED.

For example, did you find it tricky or was it straightforward? We've got a sample answer here.

I found the setup was quite straightforward, but I did have to follow the instructions carefully for each step.

I also remembered to use the correct GPIO pin, number 25 in my code.

Did you find it quite straightforward, or was it a bit tricky? Remember, you can always pause the video here, and have another go at setting up if you need to.

Okay, so we are moving on to the third part of today's lesson, and you've done a great job so far, so well done.

We are now going to create a working circuit using a microcontroller.

Once the Pico is set up correctly, it can be used to control an external LED.

So, a bit like this component I've got here.

To do this, you'll need a 50 ohm resistor, an LED, and two male-to-male jumper cables.

So here I have my 50 ohm resistor.

I have my LED, which we've seen previously, and I've got my two male-to-male jumper cables.

Connect the components to the breadboard as shown in the diagram.

Note that the resistor is connected to pin 15.

So you can see that GP15, is at the opposite board to pin 25, which we were using earlier on in today's lesson.

So, you'll notice with the LEDs that there is a shorter and longer leg.

The longer leg of the LED or the plus, should go to the resistor.

So, you can see on the diagram that the longer leg is on the bottom of the board where the resistor is.

The shorter leg of the LED, the minus, should go to the black wire that is connecting to the ground.

Once your circuit is set up, use the same code as you did for the onboard LED, but change the pin number to number 15.

So, we've got the same line of code for line one, but on line two, we are changing the second line that says LED = Pin this time we have (15, Pin.

OUT) and then, led.

value(1) to turn the LED on.

The LED should light up when you run your code.

Oh dear, Izzy's come across a problem.

She says, "Something's not right, my LED isn't lighting up.

What's wrong?" If your LED doesn't light up, check that your components are connected exactly as in the diagram, and that you've used the correct GPIO pin in your code.

Remember, it's pin 15.

If you need to, pause the video here, and look carefully at the diagram.

Okay, we are moving on to our final task of today's lesson, task C.

And you're doing a great job, so well done.

For part one, if you can, follow the Task C activity 2 instructions to create the circuit and turn on the external LED.

Remember, the instructions are provided as additional resource for today's lesson.

For part two, describe how you found the process of building the circuit and controlling the external LED.

For example, did you find it tricky, or was it straightforward? Pause the video whilst you complete the task.

How did you get on with task C? I'm sure you did a great job.

Well done.

For part two, you were asked to describe how you found the process of building the circuit and controlling the external LED.

For example, did you find it tricky or was it straightforward? Let's have a look at this sample answer.

I managed to build the circuit pretty easily, but I realised I connected the LED legs the wrong way around and had to change them around.

I also forgot to connect the black wire to the ground or GND, so my LED didn't light up until I connected it.

The code was straightforward as I just modified the code from Task B and changed the pin to 15.

Did you find it tricky or was it straightforward? Remember, if you need to pause the video here and go back to the instructions to get your circuit working correctly, you can do that now.

Okay, we've come to the end of today's lesson, "Introduction to Physical Computing".

And you've done a great job to get used to all these new bits of hardware, so well done.

Let's summarise what we've learned in today's lesson.

Physical computing is when you connect physical objects to a computer, and use code to control them to interact with the physical world.

Microcontrollers, MCUs, are small self-contained computers that are designed to perform specific tasks.

MCUs have programmable inputs and outputs, built-in memory, and a processor.

I hope you've enjoyed today's lesson, and I hope you'll join me again soon.

Bye.