[Music]
welcome everybody to the last class
of linux and electronics a raspberry pi
course
today we're going to be doing a fun
a fun uh class we're gonna have a fun
class
this is where everything that we learn
comes together
and hopefully after this class you're
gonna be able to do some fun stuff
okay so now today we're gonna be i o
scripting we're going to be um doing
some scripting for the
pins that the raspberry pi has
uh and we're gonna be using three of
your of the
of the components that you got on your
kids
okay so a reminder from the last class
was
that there's a library called gpio which
we use
on the on python which comes by default
on the raspberry pi uh image
so there's two types of the uh
of way of of of uh declaring
which kind of numbering system you're
gonna be using
one is the board which is going to be
these numbers at the center
one two three four five six and so on
and
the other ones are going to be the bc
m which are the the numbering system
from the chip
that the raspberry pi uses for example
if we're using pcm we're going to call
this pin gpio14
but if you're using the board we're
going to be using
eight right
okay so um we're gonna do
again some blinking uh we we saw that
that uh the last class but today we're
gonna be
we're gonna add something more to that
so a little reminder and i'm going to be
explaining what we
uh in case you didn't accomplish during
the last class now i'm going to give a
full explanation
so an led is an electronic um
device or or part
that when you put current through it
it lights up so it converts current to
to
to light and it has a polarity which
means that
you don't you cannot put it in in in one
way
or in both ways you have to put it a
certain way
it's imagine a battery which you have a
a positive and negative
the led has the same polarity right
this is a resistor which you could
came with and this device electronic
device
doesn't have a polarity so you could you
could have
put it in one way or the other
but the led you should put it in some
way specifically
this is i like this image because it
tells you
how to tell which one is the positive or
the negative depending on which kind of
led you got
some leds have this part cut it off
so you can know that that's that's that
side is negative
what i usually do is that i found i put
the led
uh in front of a light and i see which
is the smaller part
inside of the the plastic
colored part of the led that's gonna be
the positive
also i don't know if you notice but also
depending
they come in two sizes so that's
that's uh that's also another way to to
see which one is uh which polarity each
one
not only the sizes but some leds have
this um bended this pin bended
so you can also know which one is the
positive for the negative
so um last class we i explained how
how
how each part of the breadboard
how how how it's been connected to the
other one so you can make a circuit
right
um so yeah here
as you can see this pin is connected to
through this cable and this pin is
connected through here
all of these pins but for the circuit
it's only connected to the rest to the
resistor for the circuit's sake
which makes a closed circuit here
which is redundant right
any and and once we put a
signal it should it should light on
so this was an example of what
um a simple led script
on python should have been or it is
um we create the python script we give
give it permissions
i as you see here it's missing the plus
x right
as we all know x because of uh
executable
and then you need to execute it after
you add all the lines on the screen
so let's go over over the script one
more time a little bit quick
uh here we imported here on this part
until here we import the library
and then we use this uh
um i don't know how to call it but let's
we use this part
to call it to say that we're going to
call it this way
in linux there's a command called alias
which is
is it's working like this one every time
you call this
the program knows you're meaning this
this is important because
if if we're not using this one we need
to uh put the raspberry pi dot in front
of
every time we put gpio on this program
specifically
um and then from the library time we're
importing the
the program slip which we're gonna be
using for
timing and delays uh
here we set some warnings off just in
case we don't want them on the
on the console to be popped up
then we set the mode which was which is
what we were explaining before um
the gpio uh system that we're gonna be
using is the board one
right you can use either one if you want
to test it that's fine
but you need to be aware of that and
we're setting it up as an output
gpios or general purpose input outputs
our pins on microcontrollers and
and single board computers as the
raspberry pi which they can act as an
input
or as an output you need to mod you need
to declare
how it's going to behave and then you
you
you put it into use for example here
we just use it we're just gonna use it
as an output
and this program this part of the
program from here
down while true in python means that
this is going
to run forever this is not going to end
so you just
for ever ending cycle as long as the
program is running this
part of the program is going to be
running so we use this part from here up
as
to declare things for the program
to to this down part of the program
run correctly so here
uh we do sleep one which means
you're going to stop the program for one
second
okay and then you do
you declare this pin as a low so you
we send a a g and we connect it to the
ground
signal and
then one second we stop it and then we
go high again
okay we'll put it high if you run that
program
then you're gonna have a forever
blinking for
uh and and it's going to blink every one
second
that's what you're going to have so let
me go ahead
and connect to me to my raspberry pi
okay i have it here already
so here we are on the raspberry pi
someone asked me to to put it on full
screen
let me see if i can put this um
more default size
a little bit bigger 20 maybe
oh no that's a lot but a second
let me put this
16 maybe yeah that's gonna be fine
okay so let's
let me enter to the here
so as you can see here i have a couple
of programs which you're gonna be
seeing this class today already made
so let's see the led
dot pi which is the one that we saw as
you can see
here
this is the same program that we had on
the on the on the presentation
so if i can if i run it python
3 led dot pi
you're gonna you're not gonna be able to
see it but my led
is lighting up oh one important thing
which i almost was forgotten
um the resistor needs to be a certain
um a certain uh
amount of has has to have a certain
amount of resistance which is
measured in ohms ohm
you can find it i usually once
when i uh if i ever forget i usually
search it on google i search um led
red resistor raspberry pi
and usually they tell me which one it is
after that as you can see they don't
have numbers
they use a something called color um
code
which you can also find on the internet
you can each color means something the
first two
means the first two numbers of the
resistor
the n resistance resistance
and the third one means that
that first two number are going to be uh
multiplied
by 10 up to the number that represents
the third one
okay so in case you don't know and you
don't want to go
too deep into that you can just search a
color code
uh uh adafruit has one and
many sites on the internet has one you
just put the colors and
it's going to tell you which resistance
you have in the hand
so each uh led uh depending on the size
and also the color
has different um resistance um
requirements usually
usually from there's you can put a 200
ohms
resistor uh in there and you're gonna be
fine
okay so
uh but in this case i mean in the
raspberry pi
okay so uh let's go over here
so yeah so as you can see i i
we're going to connect it to the 40 40th
pin
on the board um let's say
numbering system which is this one
i used this too so i connected the the
negative or the cathode
from the or negative part of the system
which you can just put it for example
the resistor could have been in positive
or negative for this case okay
so you could just put it here and
connect the positive
uh right on the led and the resistor
between this pin and this one
um i what i choose to do
was to put the negative right um
from from the resistor put the resistor
to the negative
or the cathode pin on the led
and the positive to put it on the gpio21
or
40th in the board nomenclature system
so this is the other uh
program that i did uh that that i'm
going to show you
the l this in this program the led as
you can see we have
this part almost the same but we changed
this part so i can
so you can see some cool things about
declaring the variable
uh a variable with the number of the pin
that you don't have to
change every time you need to be
changing from system to system or pins
from pin
you only need to change once the the
number
so you declare this variable called led
underscore pin as 40 which we're gonna
means that that's going to be the 40th
pin right
but that doesn't mean that now it's
going to mean here
once i call the setup function
and i call here so this and as you can
see this and this are the same
just i'm using a variable so here
um so then i declare it as a law as a
law
first so because um that's going to be
my normal state of the program
and then as you can see i made another
uh
right through which means this part of
the program is going to be run forever
here are some fun stuff
let me put it full screens i can so i
can explain better
so this program sub process as you can
see i imported
another library called superprocess this
allows me
to run commands on the linux console
but from the platform of python program
this is not the only program that does
that
this is not in any way so you can find
more programs in case but
this is um kind of a standard
and yeah so first of all
i'm going to call another variable and
i'm going to put
a string into it this string
i know it doesn't look like it but this
is a command from linux confine
which is for finding it there to find
uh or and search directories
and files in linux so
i'm i'm i'm looking for this file
in the same directory that this program
is running on
this program right now as you can see
here
the um led os
is in the desktop and if i
and if i do this by the way if you want
to stop a program
from running you just click or you're
just pressing your keyboard control c
which is going to uh keep is going to
trigger a keyboard interrupt
for the python console and it's going to
tell you to stop
this is going to here as you can notice
this is my my trace pack
that this is going to tell you when the
line stopped
so in case you want to debug it
sometimes it it it has helped me to
debug
when a program is stuck um so yeah as
you can see i'm in the desktop and as
you can see i have
the uh the led os program in my desktop
[Music]
so this program find here txt
we're gonna run it i don't think we have
yeah we don't have the
the the the file here txt
so i'm going to look for it
there's no file in directory if i do a
touch
here txt which is going to create it as
you can see it
right on top here and then i do the
program again
you can see that it is there
so let me delete it
there you go so we're good to go
so here's the program this is a way of
calling this
uh this uh function of this library
which is called which is called call
you put here the program you tell the
child to be true this is something
don't don't worry about this if you if
you're gonna use this program i suggest
you to read it
but for this purpose it's going to work
just fine
so i'm basically making another uh
shell to be popped up and it's going to
run this program
and the result of that is going to go
here on this variable that i just
created here
which is called process i'm going to
print process
and if process is zero
that means it's founded it found the
file
and and everything else any type of
any any type of other output is going to
put the led low
so i want you to try that to to make
this
you can also do more fun stuff as
putting the cron tab
uh to create a here txt every one minute
and and maybe uh putting here in
in if we found it put up some some
five second timer and then call the
process to delete it
that could be fun right so i'm going to
test that right now
hopefully everything goes well iphone 3
and the os
okay so as you can see it's going to be
running forever
right now it has a a a a
um output of one i don't know if you
remember
from i think it was the second class
where we were talking about the standard
output input output and error
so it's done usually a standard error
gives you a one as an output and as an
ascended standard uh
and if there's no error it's going to
give to be giving you a zero
that's why and let me let me check here
so you can see that it's the same
program
that's why when it's a zero
then the the the gpio uh
the pin 40 goes up and and it turns on
so um let me run the program again
and let me show you as i here create
a file called here txt
as you can see once i created it right
away it started to
to to to um find it found it
and then um the output became
zero if i delete it
you can see that it doesn't find it
so yeah that's what these programs do so
you can do this
like imagine you can do a um
um turn the led every time a backup file
is generated or something like that or
to or turn a
a uh something up like
a ac or something every time
the file the backup uh is made
with the crontab for example so you can
do phone stuff with this right
so this is a way to interface things
that are happening in the operating
system
to the real world with that with an led
so let's talk servos this is the second
part that we're going to be using from
the kit
um servos are a type of motor
that are are made from
three things basically a potentiometer
which is going to be reading
where the gear the outside gear is going
to be
uh a circuit of control which is going
to
be doing that conversion from the signal
give it you're given
from the uh microcontroller or the
single board computer
reading the potentiometer to be to make
sure that
when if you tell if you tell it to go to
somewhere
and it is already there the the circuit
knows and doesn't move the motor
and also to control the motor to move
whatever it has to go
so the motors that you have which is an
sg90
if i'm if if i'm not mistaken
has it it looks something like this
but smaller this is a bigger one okay
this gearbox are used to
put some to make the high
the high speed uh low torque
motor to convert energy into
low speed and high torque that means
that
you can move uh um
bigger things uh with with this kind of
servos
i mean with servos compared with
compared with
the motor that is inside of it okay
so they are controlled with something
called pwm which is a kind of signal
that you can get from
[Music]
controllers and single board computers
right now
the uh raspberry pi doesn't as i'm aware
is it doesn't have
a pin that has a pwm
let's say from the mic from the
controller that the arduino has
some arduinos most of arduinos have them
have have a pwm output if not you can
create it which i'm going we're going to
do here
in this in in this part um so
what a pwm means it stands for pause
uh with modulation that means that
you're gonna be sending a pulse and
you're gonna
this is the part that you're going to be
modulating right
you're gonna have a standard time which
is going to be like the hertz
that that device works with and then
you're gonna you're gonna change
the time the pulse is on and that's
gonna
mean something for the for the
for the part that is connected to if you
for example
call half of the time is going to mean
something if it's if it's full
or if it's low etc
so if we're talking about the servo and
how
does that means does that does that goes
with the servo
um if we send a pulse with the smaller
uh type of uh well i mean uh
the small pulse it's going to for
example go to zero if we go to the full
for the max pole it's going to go 180.
have in mind that the amount of degrees
that
the server that you have in other server
servers go to
is going to be independent so you you
need to search for
your model of um servo and so and
look for how many degrees does it have
the links that i'm putting down here are
really got a really good resources
to look for so um i'm probably going to
put them on the
on the class notes but you should look
for them okay
so how to connect the servo to the
raspberry pi
this servos the server that you probably
have
has three cables um color red
brown and yellow or orange i'm sorry
and the red ones means that's the
positive which you're going to connect
to the five bolts
the brown one is negative which is going
to connect to be connected in the ground
and the third one is going to be the
orange one which is going to be
connected which
to whichever pin you want to hook up
with
hook up with
so have something in mind some depending
on the
on the brand that you get you have a
different coloring system
usually the red stays the same
and the dark color which is probably
black or brown
is going to be the negative and the
other color in this case are yellow
orange and
white are going to be the signal so
that's
that's the pin that you're going to put
on the
on the pin that you're going to control
it with
okay so this is the program that we're
gonna be that we're gonna be running on
okay uh this is a standard right
here uh we called for the gpio pins here
we're looking for time
because we need to be um
to just uh to have some delay
remember that when we're working with
mechanical parts
sometimes you need time for them to move
so it doesn't matter if you it doesn't
matter that
if you take this out but this is
probably not this command
is is not going to end before this one
starts running so you need to put some
time between the commands
when you're working with motors as this
one or for example stepper motors
so it can move okay
so here um we're gonna be using
the eleventh pin of the gpio board
standard
and we're gonna put it as an output then
we're gonna call
the the pwm function from the
gpio we're gonna put it to this
pin and then we're gonna put the
um the hertz
that that server is working on okay
um this is the start means where is
going to start
um uh as for example the initial
movement
so here this is where the program starts
if you run this program let me do this
right now
let me show you that i have to some
program several
here here import the pain
set mode setup pwm start
and the duty cycles the duty cycle
is something that you can that you can
calculate of of of us
um the pwm that you're gonna be using
so for now you can just um for this
example you just can um
think that the numbers that you're going
to be putting here is going to be from 1
to 12.
so this is going to be one is going to
be let's let's say
the 0 degree from the servo
and the 12 is going to be the 180
180 degrees
so so
here i'm going to call it to the first
the zero degrees for example and i'm
going to call it into half
so let me run this one and three
several as you can see
i'm getting some warnings right so
have this this is what we disabled in
the other in the other
program which we have we have in here so
i i wanted to show you what happened
right now i don't know if you can hear
it but this my server is moving
um and it's moving from the zero to the
half
every two seconds you can change any
part of this program and it should work
just fine okay so
here i stopped it and my service stopped
too
okay
okay so let's talk about i square c
um
okay so i square c is a type of serial
communication
you can imagine that i square c is uh
as to the raspberry pi as the u as an
usb
is for the uh computer it's a way it's a
type of communication bus
that where where you can connect things
in the same two pins and you have them
communicate
uh let's say um all of them
up at the same time depending depending
on the the i square c uh bus
support supports many uh devices
if i'm not mistaken up to 260
and 56 um
[Music]
that's because of the addresses okay so
this
the ice cream c have has a number a num
and
a set number of addresses where you can
where you can um
put some device into it and you go and
every time you want to talk to that at
that device you're gonna call it for
that address and we're gonna be looking
that in
in a little bit
so first of all we need to do something
that we did on first class
which is going to be enabling the i
square c
interface okay in the first got us we
enabled
ssh i i showed you both
both ways uh the first one was
with the file once you flashed
the s the sd card and the vnc i think it
was on the second class in order for
for you to do this that i'm doing which
is like
basically team viewer like um
for the raspberry pi so we click
enable we could hit okay if it if it
asks us
to risk to reboot the raspberry pi you
should do it
if it's not then you should be fine
so um so the ice
the lcd that we got uh is supposed to be
a nice square scene
these pins are should be connected to
this
boy which is going to make if you ever
work with arduino you know that there's
a way to connect this raspberry pi
to an arduino connecting each one of
these spins
but once i found out that that you can
put this board solder it into it either
they come
solar or you need to solder it so you
put it
and you only need these four cables to
connect it to the arduino or the
raspberry pi
so this is way better you do you have
less cables more reliable it's
is it works as fast it's it's basically
the same
so if we're gonna connect it to the to
the raspberry pi
you should put the red one or the vcc
one
to the five volts right you have two
pins you can use either one if
i have my servo my led and my
lcd all connected at the same time so if
you can you can just put one in one uh
vcc and one in the other one
the g and d on the negative is going to
be on the negative right
and the other ones which are which are
the the two cables which we can see here
these are the two cables that that carry
data
one is called s sda
and the other one clc
notice that you should connect each one
of them to
the ones that are on the raspberry pi
for example you're going to connect the
sda
to the sda pin on the raspberry pi
okay and the sscl to the scl
of the raspberry pi
so we're gonna be we're gonna do
something that it's basically like
uh a lookout let's say let's look for is
something like we did
with the end map of the in the first
class to see what
ips are on the network this way we're
going to be looking
what devices are connected in the i
square c
uh bus on the raspberry pi
so let me clean this
oh and i was fine there so
we're gonna do a ls dev
which is going to show you which is
going to chose
other devices that we have on on this on
this directory
as you can see i have the i square c
one available some singapore computers
and some raspberry pi in some arduinos
excuse me microcontrollers are gonna
have
more than one square c bus so
have that also in mind
in case that for example um
which has happened to me before the i
square c
the the dubai for example two
um lcds and the both
and both of them has have the same um
addresses then you can also
simulate a nice c bus by doing by doing
a program
and seeing is is not going to happen
it's not going to
um it's not going to
work as operating system-wide like it's
going to
run in the program you can find it you
can see uh
software software um
i square c python and it's going to show
you how to make
the program is going to make uh it's
going to take two gpios
and it's going to make them ice cream c
bus
so that that's that usually happens if
you if you need to put more than one
um device and some devices
um what i mean is the same device
they usually can't come with the same
address some devices or some
manufacturers
know know about this and they
put some pins so you can change it so if
in case you're going to be using more
than one
you can change which kind of address is
going to appear on that device
so you don't have that problem so i have
this one right
and as we can see in the presentation
we're gonna to do a a
a command which comes from default on
the raspberry pi which is
i squared c detect and
with this flag we mean the first i
square c
device let's do i square c
man i square c detect so so
detect
the
here so let's look for what
that y means
okay there you go
oh okay
so let's do i square c detect
y one this is a map
of the devices that are here right as
you can see
my device is on three f
this is important and you're gonna see
why because
in order for us to be to talk to the
device
you need we need to know to whichever
we're talking to
okay
so here so the i square c driver that
we're gonna be using is you're not going
to be stuck it's going to be from a
third party
the link is down here you can just
search it
as circuit basic i score clcd
it's a good it's a good um
uh tutorial but we're gonna go down to
this part
you can read all of it we're gonna go
we're gonna go down to this part and
installing the library
the library is basically this code
you can just copy and paste it as i did
here is where i copied and pasted as you
can see here
lcd right chart
here let's see the right chart as you
can see
i just copy and paste it save it
as an i square clcd driver
dot pi let me see if i can
if i gave it the executable yes
i give them the executable um permission
and then we can just import that
that program which is this one to the
to the to the any problem that i wanted
to i wanted to be use
the lcd so
let me see here um
here okay so
something important for this um library
that we're going to be using again i
created the
the file you can name this whatever you
want but
you need uh i suggest you to put a very
descriptive name
so i created the file then i changed
the i square c bus and the address
that this library is was going to be
talking to
this is important so let me open
this um editor on the raspberry pi
and let me open this driver
in the beginning of the of the of the
file you can see that is there's ice
cross and this is address
by the way these configurations are
specifically for
this um library of driver okay so
you're probably going to find a couple
of ways to do this um on different ways
made by different people if you find if
you go out on your own
so the i square c bus we just put it
it came by default with zero i put it on
one why
because when we did the else the here
um let me do it again when we look for
the
um ls let's leave
we can just grab the s square c
right because we know how to how to
search for
free uh for a specific for a specific
query
inside of a result
here as you can see i got the sqrc
device
which is named one in case it was named
two
by or zero just in case you need to
change the library into one or zero or
two or
whatever so i change it to one because
that's the one we got
and also the address it came with 27.
some um i square c devices come with 27.
uh i see
lcd score c i change it to 3f
because again this is what we got
let me do one i square c detect again
with you guys
oops detect
y and one so you can see three f
so you change it over here
only this part save it and then we're
good to go
so the program that we're gonna be
looking at
is going to be this one uh you're going
to import it
again this this program should be made i
did it here
lcd this program
should be made in the same
directory that you have the driver in
for example i'm in the desktop i have
this the driver i'm importing it over
here and the first line
and i have the lcd.pi right here okay
so i have them both in the same
directory
i'm going to call it my lcd here this
function
the drop the lcd function of the of the
lcd
driver library i'm going to be called my
lcd
and then i'm going to call the function
display this string
which is going to be hello world if i
run this
here it runs on my on my lcd
in case this this should run if if you
have any problem
probably is because or either you don't
have the square c
and enabled if you want to make sure
enable it
i reboot the raspberry pi
through the system don't disconnect it
and connect it okay
then check again the uh
the drive the the square c bus that you
have either
zero one or two etc it should be one
if you're using the raspberry pi 3
and go for
um here and then the address of
your i square c
lcd so this should run
and it should show you a hello world
so in case
you are not seeing it try this is
something called
this is a potentiometer this is the same
device that we talked about that is
inside a servo
this is basically a a variable
resistance
which you can use um to signal that
you're doing uh changing
right something like a knob
um any in case you're not seeing
if if you don't see nothing in your in
your in your
in your lcd you just change this and and
tune it
because sometimes this is what this
changes the contrast
okay so maybe the program is running
fine
but you're not seeing anything maybe
because of this so have that in mind
also this part um as you can see this is
a jumper
but you can also use one of in case you
actually didn't came with it
you just you can use a female to female
jumper
cable that it came with your kit so you
can put it right there
but you can just use whatever you want
to short circuit
once you short circuit the back of the
led is going to light up
everything should work but if you don't
have this led turn on it's going to
you're not going to need some external
light
to to see it
okay so this is the the program
the cool program that we're gonna be
using
do you remember as we struggle in the
first
uh that in the first three
um classes on getting the um
the ip of the raspberry pi
on our network so i made a program
that imports right the lcd driver
then imported the super process because
we're going to be using some
some some common line tools with this
python program
i did the same i declare this this
function of the
of the driver right
then this is the command that we're
gonna be
sending to okay to the to the linux
and this is if config this is the device
that the raspberry pi is using i'm
connected through my wi-fi
uh with the up to my router through the
wi-fi
in the raspberry pi i'm going to look
for this
i'm going to take this column and that's
going to be the ip
then i'm going to run again as you can
see this is not the same as before we
just called in the last
in the last uh program we're going to
run this command which is this one
which is this one we're going to put
all of this condition also arguments
and then the the result of that the
result of that which is the std out
which is another output
it's going to be the ip address then
we're going to send it again as a string
and it should pop right into the screen
of the of the lcd
something that i didn't explain that i'm
going to explain now is that
this means the row
that is going to show for example
if you wanted to show in the row below
as as you can see
the lcd that you got it's called
something
it's called 16 by two so if you want to
show in the first one you put one if
you're gonna just do a second one you do
here
so if you want it and also
the zero is where it starts
so um
if you want the hello world to be in the
middle you can just put the number two
or three and it's going to be right
uh is going to be just you're going to
justify by putting that
if not just going to put it in the right
in the last i'm sorry
so here let me go to that program and
open it up
over here so as you can see it's the
same program
we're going to run it um as you can see
it runs once and it doesn't have
anything
um no specific output
because uh everything every up the
output
went directly to the to the to the lcd
screen
it's not running forever because we
don't have the while true
so in case we want this for example in
case that the raspberry pi is going
remote
we can just put this part of the program
in a while true
for example like this
take this part and
when i do the tab it makes it inside
and it tells the program
to this part of the program to be inside
of this
um function because this is a while
function
so now it's going to be run forever and
as i can see in my image screen is
telling me that i have
the ip198
which we can see right here
or let me show you what we were doing
let me let me break down this comment
for you
this python program i mean this linux
um
a command so we if we run with
a quick config and ifconfig it's going
to give you
everything every ip of each one of this
so
if we had connector for example if you
have if you have connected
the um
the ethernet cable in your raspberry pi
you should change this program to be
instead of
wlan zero to be e e t h
zero and instead of i net you just
change it to
whatever i p i probably it's the same
idea okay
to whatever whenever your ep goes on
so as you can see i just put um let me
do this
ifconfig wlan let me copy and paste it i
could
just do that so i'm only getting this
one this
i'm going to search
for inet
the reason i put a space inside of it
it's because if not i'm going to get
also the i need six which is
uh the ipv5 ipv6 okay
i don't want that one because i'm not
using that one to connect through vnc so
what i did just
was a little hack which is i'm taking
this
space too okay
so i made this so i'm only going to get
this line
so as we also saw we can use the ark
command to pass
to search or to give me as an output
the second column which is the one i
want
if you don't know which one you want i
suggest you if you ever doing something
like this i should
suggest you to do the the com the one
liner
in a command line test it and if it
works
then you know you can search it and and
then you can put it inside
your python program etc or on your
contact too that's that's very important
okay as you can see if i did one i was
going to be past
this argument or this result
this column if i do
three i'm going to get nesmas because as
you can see
one two three okay
so what i choose was the second one
to give me the ip that i have as a
raspberry pi
um so yeah that's basically
that's basically what i did with this
program
um you can do
more fun stuff with this as you can see
you can you can just
search for the weather and have it and
have it pop it up
pop it up uh every time you maybe don't
want it while true
maybe you just prune this program you
put it back to normal right
back to all everything back to normal
oops
and then you want to do a crown top
right
and then you go on top
slice
one and then we go over here
and maybe you want to know your ip every
time it boots
that's fun right
reboot at reboot python3
home pi desktop
lcd
os dot pi so
if i hyphen if i have my lcd connected
every time it would so
it boots up the raspberry pi should
should give me the ip
something to have in mind as we talked
before
um that you have to give it time for
some for
for the motor to be moved right you
remember that
sometimes um
you just want uh do you need to
wait for um
for the raspberry pi to finish
booty so
there's a command called sleep which is
going which is basically the same slip
that you have in python
as you can see it's it's the the common
line just left for one second
here for five so
if you ever want to make sure that
you're gonna get a
for example the raspberry pi still is
booting up and you don't have the
um the ip address
you just you just can do here like this
the first command is going to be sleep
30 seconds for example and then
i don't remember if it was like this oh
it was like this yeah
so at reboot it's going to wait
30 seconds and then it's going to run
this program
so that's what it's going to do it's
going to let the
operating system to finish booting up
and then it's going to give you the ip
address
on your lcd screen
okay
okay okay so
um that was everything for uh
this class i hope you liked it
i don't know if you guys have any
questions or if you want me to test
something here with you guys um
i don't know if you want me to to make
some program up
or are we or what you are is if there's
something you want to be explained again
right now you can see the beauty of um
the the raspberry pi how it goes with
making uh interfaces between the real
world and the
and the end software