Hello, friends.
Today I will tell you how to acquire analog signal and with the help of this analog signal, how to
generate a digital signal for that purpose.
Over here I have a code.
First you have to import your Arduino library to Python, then import time.
After importing time, you just set a variable board.
Inside this, you have to set up your Arduino board baud rate in my case Arduino and using and the baud
rate for Arduino is fixed.
That is 9670 and the com port is my com.
After this I want to set up the digital pinmode.
In my case over here in the hardware part, this is connected to pin number ten.
That is pin and this is my potentiometer.
And this potentiometer one end is connected to the plus five volt and another end is connected to the
ground.
And this black one is my signal.
That is middle one that is connected to the wiper of my potentiometer.
So it is connected to PIN number two.
Over here we have my analog pins.
So in the software part I just use board Pinmode.
That is my output pin.
That is for this pin.
I just use value inside this.
I just use another variable to read the analog signal that is value board dot analog read over here.
I just set the pinmode pin number.
That is my pin number two.
So x I just use the formula to convert this value because it will read this.
It will read in digital form.
So I just convert it to analog form value into five divided by 1024.
It will generate value of your potentiometer.
Okay, so I just print it over here and I just put a condition over here as you see, if the value of
potentiometer that is X is greater than three board, this will write to the PIN number ten high signal.
If it is below three volt, it will generate low signal.
And over here, I just put some time.
I just put three.
Okay, Let's say it is one second, 0.1 second.
So let's check what happened to it.
Run it.
Now, as you see, the output voltage is 2.6V.
It is below three.
So my LCD is in condition when it is greater than three.
As you see, LCD will glow when it is below three.
It is in state.
When it is greater than three, it is in on condition.
This is how you can generate different conditions using Python code.
So this is all about today's lecture.
Thank you.