Hi Community!
In this project we will see the step by step of our code and its operation, the function of this program is to be able, with a led and a potentiometer, to vary the intensity of the current that is supplied to the LED, in this case the conversions of ADC to Voltage to DAC for full operation. This code will be achieved thanks to previous theoretical classes, where we touched on GPIO topics and using the PlatformIO platform.
Step 1
First we make the circuit for our project:
Step 2
First we will do the procedure of creating the new project by the platform PlatformIO. After creating this project, we remember to put the speed of the card in the file configuration, which is about 115200.
Step 3
We start by creating the code, applying the necessary libraries so that our code can work:
Step 4
We define our input and output of the circuit, in the case of the output it would be an LED of red color and a photoresistor as input, the specifications are sought to know Which ESP32 leg matches the ADC and DAC channels:
Step 5
The function is created for the Inputs and Outputs to work:
Step 6
Then the logic of our circuit will begin, in which it can be seen that first create the variables that will then be used to save the data and print it to screen every second, it starts the code for the logic where the value is acquired of the ADC, and then with this value calculate the voltage and the DAC value, and thus obtain the output voltage of the DAC, to lastly print it in the terminal and observe the values. In the same code we will call the I/O function that we created before, where find the settings.
Step 7
Next, we will see test images where you can see that it was achieved successfully the experience: