Hello, friends.
Today I will tell you how to control the brightness of an LCD using python.
In this case, I'm just using another library that is numpy.
I just call that library, as you see over here.
Import numpy as NP, then import and max.
Import time.
After that task, start the task or assign the task task and the next task.
In this case I'm just using analog output port.
Task dot a0 stands for analog output channels dot add analog output voltage channel.
My device name is one and audio output.
I just set the my channel range.
In this case maximum is five and minimum is zero.
Start the task task start.
After this I just use start.
It will start from zero.
Stop at five and the step it will take from 0 to 3.
Now I just call numpy.
So brightness is my variable.
That is np dot arange start comma stop comma step.
Okay.
So it will start from zero and goes to five in a step of 0.3.
Now I'm just using loop that is my for loop brightness level in brightness task.
Right.
Brightness right.
Level it will take from brightness.
Then print these values.
I just use index.
Right.
Level is equal to bright level over here from the time time sleep 0.2 seconds task.
Right.
Zero then task stop after this task close.
Let's run it and check what happened on the hardware bar.
On the hardware part I just connect all three pin of led to the analog output zero and negative to the
ground.
As you see over here.
Yellow one is my ground and ground one is my positive.
This is my Led.
Now I just run it.
As you see over here.
This is my brightness level.
As you see it goes high and then stop.
It goes from 0.0 to 4.8.
And now if you want to change the time sleep, let's say it is 0.5 seconds.
And again, I am running it, run it now.
It will take 0.5 seconds and it will generate signals with some delay.
As you see, white level is from 0 to 4.8.
Okay.
Basically, in this case, it is calling numpy library.
And according to that, it will generate signals.
So this is how you can generate or how you can control the brightness of Led using Python with the help
of an eye.
Thank you.