Well, let's create our first script to turn led lamp on in of.
If you want to create any Python script, you can do that in any editor, basically, you can use even
Nonno in the terminal.
But Rosebury operating system have many different ideas that you can use, which will help you with
your development.
So if you go to problem, you will see that there are different ideas.
Some of them are for Python, others for Java.
You just pick one movies.
One is a good one.
I will pick the Python lady.
And he first first of all, I will save, create file and save it in the downloads in the documents
folder.
So let's go ahead and save as.
Me, get to the documents, create new Gorlitz robots, you can call yours whatever you want.
And inside of that folder, I will create a file.
I'm going to be let's not spy.
Now it's.
And descriptively use one of the python's libraries for Google and they will have to install that library.
So go ahead and launch the common problem of Germinal.
And here you will have to execute these commands to do a pretty good install Python three zero five
zero.
I have already installed you go ahead and install it.
So once this is done, we can start with our script and the first thing that we need to do is to import
the GPO library.
Outputs zero, another labrada that we need to import is the time.
Part time next hour will create two different variables or objects.
One of them will be for the bottom and the second one will be for the little.
So this creates the bottom sequel's GPO input output zero.
The bottom and the brackets, you need to specify the imports.
So if you connect your bottom to the import number 17 you provided right there.
My button is connected to become number 17.
That's why I have 17.
The second will be bit.
And this will be this will come again from the zero.
And the bobsleds and again, we will have to provide the same number, which is in my case for.
Next, now you can just simply turn the lamp on and on by saying that's not on, for example, in this
hotel, on the left leg lamp on or if you will see of it, will turn it off.
But first, I will create the infinite loop.
And for this reason, I will use the vile statements, while true, this will create infinite loop and
inside of that loop I will first of all, check a button is pressed or not.
So if.
Button that is pressed.
Then I would like to turn the light on.
Ls.
I will turn that off.
Keep in mind, Biden is case sensitive and the stops and the spacing is quite important.
So if you if you do something like this, it won't work.
All right, so now, again, this should already work, but before we decided, let's just fine tune
it a little bit.
First of all, I will print the message when the lamp is on, I will simply print the message right
here inside of my console and the message will be Letty's on opening's.
Let's on.
And one little piece of will simply print each of.
And also, I will give you a little bit timeout, because these while loop will execute very fast and
therefore I will put a little bit sleepy time.
So time.
Not sleep, and he will have to provide the second I will just stick with two hundred milliseconds,
which is zero point two.
And from the statement, I will do the same.
So this will delay our program just a little bit.
But it's now we can just sit on a plane and see it in action, so now it's off when I press the button.
It will say on of.
On off, and the lamp will turn on and off accordingly.
So that's it for the first script.
Again, pythons very easy, but if you have never seen Python, you may be wondering what's going on.
Biggest takeaway from this lecture is that you will have to access general purpose, input output,
zero library, and then you can make use of these functions like button or let where you will have to
provide the ports, the besim, the port number on the.