Now, the next loop is actually very similar except this time the range is
different ranged from 100 down to 0, and I gave this third argument negative 1.
So negative 1 that third argument to the range function is the step, okay?
It means what change you're going to make to the number every pass throw.
So in the first range in that first loop I just say range 100.
With that it just assumes you want to increment.
You want to add one, but in the second loop I want to decrement.
I want to subtract 1.
So I have the save that, so I say 0 comma, so I say 100 comma 0.
So from 100 to 0 and the third argument I say negative 1 to tell it look,
every pass through you should decrement this.
So it starts off at 100, then 99, then 98, and so on.
So this a range, same range, but in the opposite order, and
this time I just say post modulation.change duty cycle i.
Again, same thing.
So the duty cycle starts off at 99, which is basically 180 degrees, sorry.
It started at 100, which is a 180 degrees, then it goes to 99, 98, 97.
I put the same sleep in between, so
it slowly sweeps the other way, and that's all that this code does.
Now, if I wanted to when you write embedded code you almost
always put it in an infinite loop because what this would do is it would scan to
the left then scan to the right and then it would be done, right?
And it would never do anything again.
It is much more common with embedded systems to have them live, right?
Continually doing something.
So if I were to do that I could take this and
put a wild true around both for loops, right?
So I could say wild true and indent the for loops into that,
and then it would just scan left, scan right, scan left,
scan right forever as long as it received power.
I didn't do that so the way this code is is it will scan left once,
scan right once and that'd be the end of that.
Thank you.
[MUSIC]