2023/05/05 21:45
3/5
Arduino for ODROID-GO - Blue LED and PWM
ODROID Wiki - https://wiki.odroid.com/
Give the LED to breathing effect
With adjusting analog output value, as known as PWM, we can make the LED breathing.
Arduino gives us wrappers that helps control of GPIO pins, as well as to control of PWM features.
Generally these PWM functions calls analogRead() and analogWrite(), but it's not yet available in
ESP32 so that we should use ledcRead() and ledcWrite() functions to control the LEDs since the
way to control PWM values in ESP32 is differed from in the others.
These functions are made for using LED PWM features for ESP32, and belongs to ledc.h (LED
Control).
In ESP32, the LED PWM is composed of 16 independent channels, and we can configure duty cycles
with its resolution and wave periods by accessing these channels.
So let's get it started.
First of all, we should choose a channel to attach from the LED to. It is available 0 to 7, we will use
channel 1.
Define it through a Preprocessor, and the blue LED too.
#define PIN_BLUE_LED 2
#define PWM_CHANNEL 1
void
setup
()
{
// put your setup code here, to run once:
}