Robotics & Engineering Teacher Training
Beginner
20 mins
Teacher/Student led
+30 XP
What you need:
Chromebook/Laptop/PC

Programming Robotics

Learn basic robotic programming concepts and see an example of building and programming a robot car.
Learning Goals Learning Outcomes Teacher Notes

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Introduction

    This video discusses the considerations and steps for teaching robotics in the classroom. It begins by emphasizing the importance of preparation and planning for lessons involving technology. The presenter introduces a common process in robotics: Learn, Build, Program, and Run, using a robot car as an example.

    The video walks through the process of understanding the robot car, assembling it, programming it using a coding lesson, and then testing the code. Despite the initial failure, adjustments are made until success is achieved, demonstrating the iterative nature of coding and robotics. The video concludes by promising further examples and explorations of different robotics kits in future lessons.

    Duration: 15:38

    Video transcript: AS as a teacher when you're teaching robotics in the classroom well first off students will be using technology and that needs to be set up powered or charged fix if it's not working and sometimes shared between students so it takes a bit of organization and planning and you need to factor in some extra time to get the computers and Equipment set up for the lesson now as you and your students do more and more robotics lessons you'll all get more familiar with everything and the time you need to get set up will shrink plus there's always a few students that have a good aptitude for it and they can act as your helpers in the classroom there's lots of different classroom robotic kits that are available to use there's hundreds to choose from and the list is getting bigger all the time as new kits are developed we'll go through some of our favorites later in the course but to use them they all have basically the same process one learn what it is two buildish three programmers and four runners okay so let's run through those four things in more detail using this robotic car step one learn what it is at the beginning of your class you would go through with your students what you're going to be doing in the class what equipment you're going to be using what it does so Step One Is to learn about what it is in this example we are using the kitronic move motor car it is a programmable robotic car that requires a micro bit to be slotted in and act as its brain so if we just learn a little bit about it so the move motor car has got DC motors that we can program it's got four LED lights on them that we can program different colors it has line following sensors a distance sensor so a sonar it has audio feedback so there's a buzzer intercept which you can program it has a pen Mount so you can insert a pen into it and programmers to draw different things on a piece of paper and it has Servo connections so we can actually further connect other devices to it so moving on to the next step which is to build it when you do use robotic kits in the classroom particularly ones that are designed for Education they will normally come with some really good instructions really easy to follow on how to use it and construct it and build it so this is no different here so we have a pamphlet here and it just goes through what are the contents of the case some details about micro bits and then how to arrange the kit and build it so the kiss contents are the car the chassis itself which each of the motors and all the different sensors two wheels and two tires so to build it let's move this edit away we just construct the wheels snap on the tires and two so then we just need to line up the hole in the tire with the plastic part sticking out of motor like so and just push it in firmly and the same on the other side it takes four AA batteries and finally we just need to slot in our micro bit into the car into the slot and that is the robotic kit fully built so now we're ready to move on to the next step which is to program it for our programmers example we're going to be using the line following car project from our robotics course so this just has some information about what we need a computer laptop microbrush the move motor car some a batteries and the USB cable and it also gives us the full solution if we needed that but we're going to work our way down through the steps and program the car okay so step number one this just gives us a bit of an introduction about the car and tells us what we need and also it has a download if we wanted to get we've wanted to print out some tiles for a track we're not actually going to use these in the example we're just going to draw a track on some paper using a black marker so I'm just going to mark that step as done get my reward and move on to step number two okay so step number two we're going to actually create the projects so here's where we're going to open up the website where we're where we're going to be creating our code so it's the make code website so if I click on that it'll open up the May code website for me and as you can see I've created lots of different projects before but to create a new project I just need to click on this new project and we type in what we're going to call it so line following car let's actually spell it correctly and it'll open up the microbish project editor now later in this course we're going to go through this in a bit more detail but for now I'm just going to give you a quick Whistle Stop tour around the May code microburst project editor so on the left hand side here we have an assimilator of a micro bit so any codes that we add for our program will simulate here so we can actually see it play out and run it here in the middle here we have our palette or as I like to call it the toolbox that has lots of different categories of code blocks that we can add in to our project now when you are adding some code all you need to do is drag and drop it into the code area which is this big area here and once you add in some code your simulator will refresh and then it'll run the code so we can see it saying hello an exclamation mark okay so we'll get rid of that and finally day in the bottom here we have our download button so once you have completed all your code you have tested it in the simulator and you are ready to download it onto your microbit device and what that does is it packages up all your code into a file and saves that on your computer you can then transfer that file onto your micro bit using a USB cable and that's how you load code onto your micros but we'll go into and out in more detail later on so I'm going to go back to my instructions Mark that as done and get my reward and move on to step number three okay so here in Step number three we're going to add in an extension and this will often be the case when you're working with robotics so for the Microbus there are lots of different robotic kits that you can get and a lot of them come with extensions extensions are some custom blocks that lets you program that device so in this case we're going to add in the extension for the move motor electronic move motor and what that will do is it's going to add in a separate category into our toolbox of all the different blocks we can use to interact with the lights the sensors the motor sounds and pins if you want to work with the servos so we can get a little tip here on how to add in an extension but I'm just going to go right ahead and show you so if I switch across to my project editor I'm going to click on Advanced and then I'm going to click on extensions and here we have a whole library of extensions that we can add in what I'm going to do is just search for move and that should show me the results and here we have the very first result is the kitronic move motor I click on that once and the project editor will reload and we can see now we've got the move motor category here in the toolbox with all the different blocks that we can use to interact with it okay so let's mark that step number three as done and we will move on to step number four okay so step four create the variables so what a variable is is just a name we give to store a value so we're going to create jury variables a left variable a right variable and a difference variable the left variable we're going to set that to be the left line following sensor value so underneath the car there's two sensors a left line following sensor and a right line following sensor and these will give a reading to determine how dark it is underneath whichever sensor and what we're going to do is just store that value earn the left variable and store it in the right variable for the right line following Center so once we have those set we're going to subtract the right sensor value from the left sensor value and that will give us the difference and depending on the difference we're going to know if the left line following sensor is over the line or the right line following centimeters over the line and then we can make it turn left or right or just go straight accordingly so let's create these variables in the project so I go to my project and open up the variables category click on make a variable and type in left again let's put in the correct spelling and then right and finally let's create one for difference there we go we've created three variables a left one a right one and a difference variable and as we can see we can now have code here where we can drag and drop in and we can interact with these variables so we're going to set these in the forever block so let's set the left one first and we're going to set that to the left line Center value we'll duplicate this so we can be nice and quick and change that to the right variable and we'll set that to the right line following sensor value and finally we want to set what the difference is and as we said we're going to subtract the right variable from the left one so we're going to math and we'll get a minus and into variables we get the right one so we're going to subtract that from the left one so as we put those inside a forever block this forever block is just a loop block so whatever's in here just keeps on happening over and over and over again which means in our car a robotic car it will constantly know what the left line following sensor value is the right one and then what the difference between the two of them is so we're going to move on to step number five where we're going to set up the LEDs as we mentioned earlier the cars have got LEDs on them that we can program and to program them first of all we need to create a variable that's going to store the LEDs so we can interact with them later so we can say if we want to set them red or yellow or do different things with them but first of all we just need to set them up at the start so we're going to put some code into the OnStar block so if I go back into my code and I drag this across let's go into move motor and lights and here we have the code we want to set move Motors zip so it's going to create a variable called move motor zip and we're going to set that to be the LEDs there's four of them on the card so that's why there's four in that block and Mark our step as done and get a Christmas gift very nice and now we'll move on to step number six where we're going to turn right so we have our three variables that are constantly being updated inside the forever block we're going to add in some code that is going to check if the difference variable is greater than 10 that means we want to turn right so to turn right we're going to turn off the right motor and then we're going to turn the left motor forward at speed 10. so let's go ahead and add in this code so logic if then else and we want to go into the logic again and get a greater than though it's less than at the moment but we'll change it to be greater than and what we're saying if difference is greater than 10 turn off the right motor and then we're going to spin the left motor or turn the left motor Direction forward at speed let's say 10 for the moment and this helps with the testing I have to see if our code is working so where is Show color and we are going to say yellow okay so let's mark that step is done and let's zoom out to get our GIF reward okay so now similarly we're going to add in some codes to turn left so this is basically the same except it's reversed so we're going to say if the difference is less than -10 then we're going to turn off the left mode or turn the right motor and we're going to show the color red so let's quickly go ahead and do that by just duplicating the code and then objecting it so turn off the left one spin the right one and what color did we say we said we are going to do red okay so change this to red there we go and then finally we are going to duplicate the condition and say if less than minus 10. Mark that step as done get our reward and let's zoom out again okay so now step number eight we're gonna go forwards so if the difference is not greater than 10 and it's not less than -10 then the left and right have similar readings or close enough to similar reading readings so we should move forwards so we're going to add in the else into the if then here and what we're going to say is Motors we're just going to say move forward at speed 10. and we will show color green okay let's mark that step as done and get our reward a surfing dog Okay so we've added in all the codes that we need to program the car so the next step is we're going to download it onto the micro bit so we can actually run the code and test if it works so to do that we're going to go back to our project editor so to download the code all we need to do is just click on the download button here and what that is doing is it's going to package the code into this file here micro bit line following car hex and then we just need to download that file onto our microgrid so we can open up the folder so to send the file to our microburst we just need to right click on the file go to send to and then click on microbish and what that will do is it will transfer the foil to our micro bit so it'll overwrite whatever code is currently on our micro bit which are new codes that we just created the last step is to run it I've downloaded my code onto the micro Ridge that's inserted inside this car and now I want to run the code to see if the car follows this little truck I've drawn on this piece of paper this is the step where we test to see if our code works if it doesn't work so if we observe instead of turning right if it turns left we need to go back to our code fix the code and then re-download it and we need to run through that cycle until we get it working correctly until we observe that the code works correctly okay so without further Ado let's try and see if it works great success it works so I've programmed the car to follow the track again if it didn't work we'd go back to the code fix it and test it again and run through that cycle until it works so generally that's what programming robotics entails learning about us building us programming and then running us we'll go through some more examples later in the course of different types of robotic kits you can use foreign

    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more