Professional Documents
Culture Documents
Sensor de Temperatura
Sensor de Temperatura
INTRODUCCION
Empiece por definir el pin al que está properties, different than these, to generate
conectado el LED. En este caso el LED está different PWM signals.
conectado aGPIO 16.
const int ledPin = 16; // 16 corresponds to const int freq = 5000;
GPIO16 const int ledChannel = 0;
Then, you set the PWM signal properties. const int resolution = 8;
You define a frequency of 5000 Hz, choose In the setup(), you need to configure LED
channel 0 to generate the signal, and set a PWM with the properties you’ve defined
resolution of 8 bits. You can choose other
earlier by using the ledcSetup() function that signal is the ledChannel, that corresponds to
accepts as arguments, the ledChannel, the channel 0.
frequency, and the resolution, as follows: ledcAttachPin(ledPin, ledChannel);
ledcSetup(ledChannel, freq, resolution); In the loop, you’ll vary the duty cycle
Next, you need to choose the GPIO you’ll get between 0 and 255 to increase the LED
the signal from. For that use brightness.
the ledcAttachPin() function that accepts as
arguments the GPIO where you want to get for(int dutyCycle = 0; dutyCycle <= 255;
the signal, and the channel that is generating dutyCycle++){
the signal. In this example, we’ll get the // changing the LED brightness with PWM
signal in the ledPin GPIO, that corresponds ledcWrite(ledChannel, dutyCycle);
to GPIO 16. The channel that generates the delay(15);
}
DIAGRAMA
CONCLUSIONES