Up to now, we have been programming the 3-2 by having it constantly connected to the computer and we
were able to click on the green button to get the program to run.
I imagine when you have finished development and you want your hospitality to be independent of your
computer and to be able to automatically execute a given script when power is applied.
There's a couple of ways by which you can do that in this.
Let's show you both of them both ways involve the supply file.
So the bid to be fine as long as it exists, is going to be the file that the EPA authority will attempt
to execute when it's powered up.
You can see here that in this instance, it does have some code in it, but it's all commented out.
And that's why when we do start the hospitality, nothing happens.
There is code that is coming out is not going to be executed.
You can replace this code with your own code.
So I'm going to do this right now.
I'm going to copy the code from previous lecture and I'm going to pasted here.
It's going to leave the previous committed out code as it is.
I'm going to paste it in here and then save this file.
Now, what I'm going to do is I'm going to disconnect the computer, cable, USB, cable, and I'm going
to replace it with a cable that I have connected to a power supply.
This one's a battery power supply and plug it in and you can see the reality is blinking, meaning that
my code in the P.
Y script is being executed.
So that's the first way.
Could you connect my Richard back to my computer and now let's see what happens.
Remember that pill, one that contains code and my attitude is executing it, which means that it's
locked inside this loop, going to click on the stop restart back in button.
And.
I'm not getting any files in the file browser for the connected device.
Because, again, the device is busy executing the Blink script, so I'm going to send a control scene
to interrupt the execution so that the device is released and I can continue to interact with it via
Sony.
So that's something to remember.
When you do have a script that contains infinite loops like that, you need to remember to hit control,
see to regain control of the device.
So the first way is to just simply copy your code inside the file and then it will execute the contained
code.
But a better way to go about doing this is to use input.
And because we already have the code that we want to execute on bood in a separate file, we don't want
really to copy across into the boot.
So a better way to do that and reuse the work that we have already done is to use the import function
and just simply import Elida.
And it's called Blinkx without the extensions.
So this.
To save this file, so say the new version of Bitter Pill, why so what's going to happen now is when
power is applied to the big three to it is going to look inside.
Would it be wise for executable code?
It's going to find a link to the ality and it's called blink.
That file will import it and they will execute it as it comes in.
And the effect is going to be exactly the same, except that now we can continue working on our ALYDA
linked or Peepli File, knowing that it will be executed on boot up because of the input instruction
in line seven of the top file.
So I've got my input statement here.
But just one thing that I've noticed is that the ability in cobbling to Kidwai file is not my ISP through
the device, it's on my local file system, so I won't need to bring it across.
I believe there is this file here, so I'm just going to upload it.
And now that it is here, that reference will actually be correct and it will work.
All right.
So I'm going to unplug the data from my computer and then bring the power cable from the battery room.
And there you go.
It works.
Let's connect back to Sony, and it's like power, like two computers, USB, cable.
And the hospital, too, is now locked into the infinite loop.
So I'm going to hit on the stop button to restart the back end.
And then control, see?
To stop the execution and we've got control back.
OK, so let's sit with the two methods by which you can automatically run a program on time or power
up on your AHP suited to the last thing that I want to show you in this section is how to do simple
debugging of your of Python scripts using phony I.D. And we'll do that in the next lecture.