-------------------------------------------
Hyundai Elantra 2017(Euro Truck Simulator 2) - Duration: 3:59.
https://www.youtube.com/redirect?event=video_description&v=n6pT8YCMUHE&q=https%3A%2F%2Fgoo.gl%2FRikPuV&redir_token=twu9Wlg8yDknf5Js3qtXTt5dAFd8MTUyOTQ0NDIyMEAxNTI5MzU3ODIw
-------------------------------------------
Arduino Made Easy(er) The Welding Sketch - Lesson 08 - Duration: 34:45.
welcome to another episode of Arduino Made Easy this is lesson 8 and we're
going to go over the welder scene that I did on a previous video so let's see how
we did that I'm Tom Kvichakc and this is Toms Trains and Things this channel was
created to help other modelers who are need of guidance in pursuing their dream
of building a model railroad we're going to put some animation in our model
railroad today with this sketch of an arc welder and some building lights and
I showed you in a previous video how I did that now I'm not going to take it
apart and put it together because that's going to take a long time because we got
seven LEDs on there and we have a sensor now this sensor is the same sensor that
I used for the gate crossing it's a IR sensor I'm gonna plug this in so you
could see what this actually looks like
will actuate it and you'll see the four LEDs come on right here and once those
four LEDs come on then the arc welder will come on now well how I have it and
the sketch it'll go through the cycle three times and then it'll then it'll
stop so that's two times right there and it'll go through there one more time and
it'll shut off by itself you could set this for how long you want it to stay on
you could set it for how short you don't even have to have this sensor on here to
even start it up you could do it without the sensor and have it come on
automatically as soon as you apply power to it so I just wanted you to see the
the sequence of events on here I have all these set at a two-second delay if
you would like to see more videos like this go ahead and hit that subscribe
button and while you're at it doing that also you could be notified whenever I
have a new video coming out check out my playlist on the playlist page I have a
lot of playlists on there that are categorized for easy discovery so check
that out now let's get started with this sketch
right now so let's go over to here now you can see I have a few notes up here I
have this adapted for the the pro mini because that's what I have on my layout
simulates an arc welder and other Lighting's in the scene building lights
are seven eight ten and eleven and arc welder is pins two three and four where
pin three is a pwm pin that's because we're using an analog right to the glow
pin so let's start typing in here now we have the four LEDs for the building so
we're going to start with that and let me do it this way here all right so we
got integer any it's oh yeah that's awesome ledB1 equals seven Mt we
need db2 equal 8 TB three equal nine and tdb4 equal seven eight nine ten no I got
sony 10 11 excuse me so we're gonna do it that way 7 8 10 11
I saved 5 6 5 6 & 9 those are the other pwm pins on a pro mini for a future
project I'm going to do something else on that later so I left those pins empty
for right now we're gonna do 2 3 pins for the arc welder now so int LED weight
is on pin 2 integer tell me d WP is on 3 n OT MP d DW e is
on pin for those are the photos are all the LEDs now we're going into the sensor
and the information that we're going to need
the if statement so the first first one for is the sensor that we're going to
use and we'll call that sensor one and we have that on a one now we're gonna
use a something that we did in the gate crossing we're gonna use sequence
started and we'll start that off with a as a zero we're gonna do a wait and this
is for the delay between the building lights and we're gonna start that off
with that 1000 milliseconds which is one second and then we'll have another
variable in here cont and we'll count equal three now this weld count 3 you
could change that to whatever you want if you want your welder to stay on
longer than three cycles through the procedure then you could change this
number right here on the well count I kept it down low on this demonstration
so it wouldn't take that long you could see it go through the entire process and
also shut off so I left it at 3 okay the next thing we're gonna do is we're gonna
do the pin modes okay I'm going to copy a little bit here sensor was an input
and we need one and what I'm going to do is copy this several times
I'll be two three and four so I just changed the number on unit two three and
four now I'll do it a couple more times we're
just gonna have to change it to white blue and glow cane okay so control beam
okay so LED white blue and last one we just call glow pin now we have all that
set up right there we're gonna go into the loop so we could see what's going on
with that and we're going to just put three procedures in there for right now
we're gonna create that we're going to put the procedures in here now in the
loop and then create the procedures and then write what we need to activate the
procedures so the first one is going to be the building lights being like LD ing
missing this oops Capitol building lights okay we'll come down a couple and
we'll call the next one welder and the next one
okay so those are the three procedures we're going to do in there now like I
showed you in a previous lesson we did we wrote what those procedures are
outside of the loop so we'll go down below the loop and then we'll create
those three procedures in here the first procedure we're going to do is the
building light so let's start with this we'll do Boyd Boyd building lights and
then we'll come down we'll do our curly braces and bring that down a few we're
going to do an if statement in there and we're going to test the see if the LED
b1 is on or off okay and we're gonna say if digital read LED 1 b1 is low that
means it's off and digital read glow pin is low that means that's off then we'll
run this procedure if those if either part of that is false say like if the
LED is already on we don't need to run the procedure so it'll just skip the
procedure with the if statement so if and we'll have to do it at two of those
tal or digital read LED b1 is low put another parenthesis in there and
Digital Read
glow pin is low
then it's okay to start this procedure so we have to put some curly braces in
there for this and then we'll put the conditions in there for what we want to
see so it's going to be digital right
LED before it's high and then we're going to put the delay in there right
now and we're just going to say 2 seconds so we're going to times 2 since
the delay is 1 second 1000 milliseconds now we're going to do the same thing
with all the rest of them so I'm just going to copy this right here 3 so we're
gonna start off with 4 then we're going to do 2 3 and 1 that's the way I had it
on my original sketch so 3 & 1 & you could do it in any order that you want
it doesn't have to be this order here whichever order that you want to do it
in but that's how I did it in mind you got the if statement in there if both of
those are off we're going to do whatever it says in these 4 in these commands
right here we're going to turn on all 4 LEDs and we're gonna wait 2 seconds
between each step on there and and at the end we're also going to wait 2
seconds before we do something else void you know de
and then it's put some lines up here so we can see what we're doing and we'll
also put the curly braces in there now so we don't forget them
okay void welder so what we want to do is we want to give it random on and off
in there so with that random on and off we're going to do the count and then
random and then the minimum and then the maximum now these figures could be
changed around we're going to start to count in here so we're going to use a
for statement and we're gonna say integer I equals zero we say I is less
than count
and then I we're going to sequence through it so what we're doing right
there is we're taking the count and we're going to sequence through the
count in between the random numbers that are generated from Arduino between 10
and 60 it's going to give us the on and off for the LEDs curly brace in for that
one for the for statement okay now in the for statement we're going to do a
digital write for the LED white we're going to stay high and we'll have to put
out parentheses and that right there and we're going to put a delay in there a
random delay and we'll say 60 and you could change this then we have to put
two of those in there okay let's move this give us some more room here okay so
we haven't turned it on so now we have to turn it back off so what I'm going to
do is just gonna copy this right here
and I'm going to make this low we're turning it off and going to give this a
different value we're going to keep it off longer than we had it on so we're
giving it 200 okay we're going to do the same thing with the blue so what I'm
going to do is come over here we're going to change this to blue at high and
we're going to give this a delay of 10 we're gonna so it flickers at a
different rate then the and it will copy this so all we have to do is change the
low and stuff okay so come over here blue change this to low and change this
to we'll give this a hundred okay let's move this it's move these things up here
this is now we're going to put another four statement in here for the glow but
we're going to do it differently okay so we're going to do for integer we're
gonna call this one J equal 50 and we could play around with figures on here
to make it look however we want it to look and do greater than one and
J and we're going to we're going to decrease it so we're going to start at
50 and work our way down to one and so after that we need to put in curly
braces for that one okay and then we're going to do a right here analog analog
right on the globe pin
and with the value of J and we're going to delay that about 100 I have to set a
delay for the entire procedure so I'm going to do it you delay random here
also and I'm going to set these to eight hundred and two thousand and then we
have to put two closing braces in there and then that right there okay so there
is the welder now what we have here on the on the welder sketch is okay we have
to count random 10 10 as the minimum and 60 is the the high and then for the
integer zero integer less than count so we're going to take that and we're going
to count up between 10 and 60 at one step at a time for the welder and so in
the digital right for the white we're going to put a delay in there a random
of 60 and that a maximum that's not saying it's definitely 60 when you say
random it's when you have one figure in there that is the maximum figure if you
have two figures in here like that you have the first figure which is minimum
and the second figure which is maximum so that's what we're going to do we're
going to step through the white and turn it on and off at those random random
times right there with these random times so it's not all the same and do
the same thing with the blue but at a different rate than the white and then
on here for the glow pin we're going to turn the
pin on after the white and the blue is finished and it's gonna start up high
and it's going to it's going to start up high and then get dimmer as it goes goes
down to to one from fifty as it counts down from fifty to one it's going to get
dimmer so that's simulating the the glow on the metal when it when they bring the
stick up off of it it's glowing real bright and as time
goes by it'll get dimmer and that's exactly how a welder works come down
here we're gonna do video D and you t do W and I don't think that's how I did it
shut down yeah with an underscore okay so we're gonna work on that right now
and all we have to do with this right here is just shut all the LEDs off so
let's let's just shut the everything off here and so this is another thing where
we're going to put in the curly braces first and then give us some room here so
we don't have to do it at the very bottom of the screen okay so we have our
beginning curly brace so everything that's inside of that will be in the
procedure for setting it down so we're going to have to do a digital right
led and we're just going to start from the beginning the b1 and we'll do a low
and a semicolon and so we're going to do this to all the led so I'm just going to
copy this right here okay two three four and then the three group glue in the
three other pins okay so we'll just change this to two three four and then
led this one will be white
this one will be blue and this one will be glow pin
oh I could put an analogue right on that okay we put an analogue right L ugh
right on to glow pin and we'll give that a value of zero because we're using the
analog values on the glow pin and so now what we have to do is we'll go up here
in the loop and play around with the loop we want to start the loop up and
what we want to do in there is we want to read the sensor 1 we want to read
this sensor right here and we want to also see the sequences like we did with
it with the crossing gate we have a sequence and we're not started yet so we
want to put in an if statement about if this is low now you remember whenever
this whenever it's not covered it's high so whenever you cover it it goes low so
we're going to say whenever we cover that up and the sequence started is zero
the sequence hasn't started yet then we're going to go through this if
statement and what we're going to do in the instance in the if statement is
we're going to say we're going to change the sequence started to true which is a
1 and then we're going to turn on the building lights so let's do that right
here so we'll come up here and we'll write if if yeah let me see on these
when you have to put - oops l digital read of sensor 1 now where we're going
to read the digital read sensor 1 we have to put a parenthesis there
equal oops equal and we want to say low because that is what's happening in in
there at this time whenever we cover it up it's going to
low and where's the end and okay is the qu v NCE
destiny or sequence started oops equal okay
zero zero okay now put two parentheses in there now what's it saying is in here
is whenever we cover up the sensor and I got to change that to a parenthesis okay
we cover up the sensor and if the sensor is covered and sequence started is false
nothing has started yet then we'll go through this statement right here
so what we're going to do is we're going to put in our curly brace but we're
going to put the other one in after here boom right there and we'll come back up
here and before we turn the building lights on we're going to say the equ is
e sequence started equal 1 now what we did there is we changed the state of the
sequence from not working - working so now we're in the sequence and we're
turning on the building lights so that's where we are right now
so what do we want to do after that we don't want to turn the welder on right
now we want to put in an if statement for the welder also so we're going to
have to do the same thing on the welder we're going to have to read the sensor
and when the sensor is high that means we're not over top of the sensor like
that so the sequence and the sequence already started
so whenever the this is not covered and the sequence has already started then
we'll start the welder sequence so we'll write that in like this
if digital right and the digital life it'll read we want to read the sensor
sensor one put a parenthesis in there and if the sensor is high that means
there's nothing over top of the sensor do one of these and okay is the qu ence
sequence started Eagle 1 and I see what I did over here I didn't need that right
there okay now I'm gonna go back there we go
that's it all right now we'll do this again put this in here and we'll put the
other one underneath the welder for the end of it okay but before we get there
we want to increment how many times we want the welder to sequence before we
shut everything down now if you want this thing to stay on you don't have to
put this next line in there if you want yeah once you once you trip it or you
don't even have to have the first if statement in there if you want to have
this on all the time you could just forget about that first if statement and
just put building lights put welder and then not put the shut down the procedure
in there but what I'm doing is in here is I'm turning it on with a sensor so if
somebody walks up to it it'll start going now I'm for this demonstration
only I haven't gone for three times so you know it doesn't have to we don't
have to sit here and watch it for five minutes but anyway we're going to put in
a for statement for the welder and what we're going to say here is four and here
we go with all those parentheses again now this is where it gets tricky okay
we're going to do an integer we're going to call this one X because we already
have an eye and a J and we don't want to confuse it even though the the other
integers I and J are within the procedure itself they're contained
within that procedure and don't go outside that procedure we're going to
call this different anyway just so nothing gets confused here and we're
going to say equal one okay if that's equal to one and
is less than or equal to and you know welder count we're gonna do a welder
count right there semicolon and then X plus plus and then close the parenthesis
and then open up that and put another thing behind the welder another curly
brace for this or behind the welder now this is where it gets tricky because
your your have multiple curly braces in here so you have to make sure that your
curly braces are in the right place so the for statement just has the welder in
there and that's what we want once this second if statement is finished it's
going to step out and go to the next line and that next line is a shutdown so
what we're going to do for that shutdown is we're going to change what the
sequence is so we're gonna say sequence started and we're going to change that
back to zero and put that there and then shutdown and that's it now we're going
to go through this and hopefully I don't have any mistakes in here
and we got to clean this up a little bit so let's see if this thing compiles okay
I'll click on that right there and we'll sit and wait if it's not doing anything
and you don't see any error messages popping up that means it's going through
there and changing it into machine language and there we go it's it's done
it's done compiled so it works so let me plug this thing in and it's already got
the sketch in there but for loop if did
you we'd sensor is low whenever I cover up
that sensor and sequence started equals zero then it'll go through it'll change
sequence started to one and it'll open up the building lights okay and then
when that is finished once the building lights are on and you have that last
two-second delay on there it'll go through this next one if digital read is
high nothing's over top of the sensor and sequence started is true then it'll
go through the welder sequence and the for statement in here where it says it's
counting and weld count is equal to three right here so it'll count it'll go
through that procedure three times and once it goes through that procedure 3
times then it'll drop down over here it'll change sequence started to false
that means nothing's happening and it'll go through the shutdown
procedure so let's walk this through right now
so I'm putting my finger over top of it and the building lights are starting to
come on ok so that's so it's in the building lights once it's finished with
that it comes into here and it counts out three cycles of that procedure so
it'll flash the white and the blue and then it'll the red will decrease it'll
do that three times and then once it does that it'll change the sequence
started to false zero and you know shut everything off just like that
now that's the procedure I have the Fritzing diagram in the beginning I'll
put it in in the end also just because I didn't show you how I hooked all this
thing up at the beginning so you know I'll have the code in there and
everything else in there thank you for watching I'll have another
video up sometime with the df' player I'm going to show you the sketch of the
DAF player that's the next one it's going to be up that's a pretty simple
sketch on there but that I just wanted to show you
how you can get to use that DF player for your sound effects on your layout so
we'll see Ya
-------------------------------------------
Starbucks & Starbucks Music: Starbucks Music Playlist (Starbucks Inspired Coffee Music Youtube) - Duration: 3:31:23.
Title: Starbucks & Starbucks Music: Starbucks Music Playlist (Starbucks Inspired Coffee Music Youtube)
-------------------------------------------
被招惹時反應最大的3個星座 - Duration: 7:41.
For more infomation >> 被招惹時反應最大的3個星座 - Duration: 7:41. -------------------------------------------
CID Officer Daya Sir & Lady Officer Purvi Enjoyed their SHOOTING BEHINDS THE SCENES.............2018 - Duration: 1:08.
PURVI &&&& DAYA SIR IS ENJOYING
CID Officer Daya Sir & Lady Officer Purvi Enjoyed their SHOOTING BEHINDS THE SCENES.............2018
subscribe to our channel for stayed connected to us
Không có nhận xét nào:
Đăng nhận xét