Welcome back to this tutorial on the Unit 6 Microcontrollers exam. Today we'll be looking at an activity which I think has got the biggest interest in it because it is the activity 4 where we're looking at the programming and part of the reason for the delay on this episode is because it took me a while to think about the best way to present this so I hope that you find it quite useful. Before we go into anything we will first be Having a look at what Activity 4 is, so in the exam it says develop a user-friendly system that is well organized, structured and formatted, including producing the software program and annotating the code, programming it but also the annotations which will be going to in some amount, the assembly of any hardware if required, so that is looking at putting the hardware together and putting your circuit together which is going to go alongside your code, making sure the hardware is working alongside the software, and then refining the system so that It operates as expected and can handle some unexpected events.
Once completed, insert the annotated code into the electronic task booklet. So when you submit this exam, you submit two files. One file is the electronic task booklet, which is provided by BTEC, and you need to put all of your written answers in there. And the other part is going to be the video that you produce in Activity 6. The only two things you submit, you don't submit your code as a file.
And because of this, you need to be able to put the... code is screenshots or something like that within the annotated task booklet what I'm going to do now is I'm going to take you through how I would build this code and I'll show you how the code that I've built for this and then show a little bit on how we can annotate the code and show how we can put that into the annotate into the electronic task booklet so here is my code and it is a fairly simple program if I zoom out here you You'll see it's not the biggest program in the world, although it's quite a bit bigger than some of the other ones I've done on some of the videos where I've been showing you some similar programs. We also have another macro in here which just makes the whole code a little bit neater.
Let's take a look stage by stage. So, to start the program, we start up the LCD screen. We're only using the LCD screen and some buttons here.
We start a loop, a while one loop. So this loop is going to be the whole of the program is going to be included in this while one loop it's usually the only time you want to use a while one loop like this so that means it'll loop around this loop forever until it's turned off start that loop we clear the screen which is good practice really if we're going to be using the screen it's just making sure this screen is nice and clear and we put use this section here is putting some of the information up onto the screen to start with and then Reset all the variables back to wherever I want them to be so I've got some different variables here You got one for the fair which is going to 150 Which is where it starts at one pound fifty fair and some other variables as well Which need to be at a certain value in order things to work and then we use this time and screen macro Which just sets up the screen as if it's going to be timing before this as well. We also have A button so we have to wait for a button.
So if I press play at this point you'll see that it comes through and it slows down just so we can see it working so it comes through it sets up everything on the screen it says press the button zero to begin the journey and then it waits until we press zero for the journey to begin and off we go so it'll go through this setup here so this will set up the screen with all of the information that we need and the program will start looping around this program so let's have a bit of a bigger look there now We've got this tense setup here. So this is just so we can check to see if we're pressing the button once every, sorry, 10 times a second. If you wanna see a little bit about this, I've put a link to that video up on the top of the screen now but it's a little way I use to make my program work a little bit better so the buttons are a little bit more responsive.
In this section here, this is what happens nine times out of ten. It checks whether you've pressed the button so It says button a variable called button equals the value of the switch and if button equals two, so you press button two So that'll be this one here sorry that'll be button one here it enables this pause situation so it'll pause the screen if you press button one it means journey goes to zero so that'll mean that it exits this loop here because that's going to stop the loop other than that it adds a tenth of a second and then if time equals 20 So sorry, every, it'll mean 10th goes back to zero and it adds one to the seconds. And then if the time is greater than 20, it's going to add 20 pence to the fare. So every 20 seconds, it's going to add 20 pence to the fare. So that fare is going to go up and then it'll be able to display the pound.
by doing fair divided by zero so that's going to give you the pounds value there so it's 20 pence and then it'll be 150 if you do divide it by zero you're left with just the one for one pound so this is what's allowing us to recollect the fair and then the fair will come on the screen if i let this play for a little while um i put it up to full speed you'll eventually see this will go to 70 pence you It does take a little while because it takes 20 seconds to do that, so I'll leave that running as we talk through the rest. And I've got a 100 millisecond delay down at the bottom here because every time it loops around, it's looping around 10 times a second. So this will give me roughly one second, although you may need to tweak this a little bit when you come to do your testing.
Once you exit, it'll reset the button value to be zero. So it means that if you press the button earlier on, the button is now going to be zero again. And it'll loop through this section until button equals one.
So what it does in this section here is this is where we're adding on the surcharges and the discounts that were mentioned. So it prints a screen about the... ... that you need for the say charging discounts and again it goes to button zero button equals zero and then while the button equals zero it's reading all of the buttons you can see now that this program has gone to 70 pence so let's uh slow it down again and we'll speed up for this and then i'm going to end the journey here So now, the journey's ended, the fare's £1.70.
I can press button 1 to add 50p on. I can press button 2 to take 50p off. and that's the surcharging discounts if i hold the button it does um keep taking off and putting on so i could have probably put a wait until low or something in there but i that is an improvement we can talk about at a different time so as it's going through that section It's looping around this here until I press Add button. If I press button 2, it jumps and puts a surcharge on and it comes back around and prints everything to the screen. So you can see it's printing everything to the screen.
If I press a different button, It'll still loop round there, but it knows that it doesn't need to do anything. So it just prints everything back on the screen. And if I speed it up, you see it just comes on straight away.
And then if I press button zero, the whole thing starts again. So that's how the program works overall. It's not just enough to make the program work, you also need to add some annotations to show that the examiner that you know what you're talking about.
So I'm going to show you how I would do that now. Now you can just use screenshots and that would be fine. So you'd be able to take a screenshot. of the screen and then crop it in another program.
But I'm gonna use a Snippin tool. And if you, on a Windows computer, if you just search for Snip, the Snippin tool should come up really easily. And you can take a screenshot of a small section of the code. So I think I'm going to go for this section here.
Use the snippet tool and I can take a snapshot of this section of the code here. Then I can copy that using control C into PowerPoint. here and we've got the program in here just like this we don't need this window on the right hand side and now what I'm able to do is I'm able to insert some text boxes and I'm able to annotate what's going on so this box is included to initialize the LCD screen and if I insert an arrow I can point to the section here probably make the arrow a little bit thicker like this You might want to change the color a little bit depending on what background you've got.
could go for a bit of a brighter color maybe red stands out well against both the light and the dark backgrounds here so you can go down you can put a number of uh text boxes in like this uh you can say this section section section of code is used to put the initial values onto the user's screen. Cursor sets the position of the screen. And print string puts text onto this screen.
You might even want to put a text box around that. So let's go for a text outline. Black there.
And... shape outline in black there so now we can see these are nice smooth text boxes and finally we might want to put something at the bottom wait until high and wait until low are used in this configuration to sense when a button is pressed but only move on when the button is released again just make sure it fits nicely on the screen so that we'll comment it up this little bit of the code and we have some good information what i'm going to do now is put it back take another snip i want to take a snip of this annotated piece of code So we've got all the annotations in there as well. I'm going to copy that and I'm going to put this into a Word document.
So I'm just using this Word document. You use your activity booklet in the real thing. And I'm going to write about this section of code.
So this section of code is the initial setup of the screen. And I'm going to copy that. and waits for user input.
It uses a series of component macros to control the screen and print the relevant Instructions for the user to know what to do. It then waits for the user's input. So you have to go through the whole code for this. I've only shown you one small part.
It does take quite a bit of time but you can see here that it hasn't taken a huge amount of time to do this section and what I would say is break your code into logical chunks. the next bit of code i would probably go for would be um maybe just this section here so going from the end of this section just to this small section here and i'll talk about this one because that is a nice little section setting up the next time and then i might go on and talk about some more about this loop it might be harder to break down into sections um but you might have to get a little bit clever with how you show it on the screen. It is a tricky section to get right but if you follow these instructions and you set it out like this where you have some direct discussions of what's going on on the screen and what's going on with the code but then some summaries at the bottom you could maybe put a bit more detail in here as ever the more detail you put in the more likely you are to get the higher marks and you really need to look out for that. Also you should probably pay attention to making sure that you are talking about your unexpected events because that is what you need to get for the highest marks.
So in summary, Activity 4 is all about the programming. It's about where you're programming the device that you need to do for the exam. But it's not just about programming it and making sure it works.
It's also about the annotations, and these are really, really key. If you're just putting your code and it works perfectly and it's amazing, but you don't put any annotations on, you're going to really limit your marks from the potential 16 marks in this section, which is about 20% of the mark overall. to three or four marks because you can't get out the first section without appropriate annotations.
There's also a few extra details that you need to include so I would probably include a picture of the hardware as you set it up when it's ready to go as well as a picture of the simulated circuit so that was on the right hand side of the screen that we're just looking at before and just annotate these a little bit explain what's going on with them but I think these little extra details where you include as much information as possible like I said earlier You want to include stuff about the unexpected event, but you need to include as much information as possible to get the most mark. That's a pretty simple and easy relationship to remember about what you put in and the marks that you're going to get. Hope you found this useful and good luck in your exams.