miércoles, 24 de julio de 2024
martes, 2 de julio de 2024
generate two clock signals on the esp32
In the channels, channel zero and channel two are used because apparently the channels come in pairs and if zero and one are used, they will have the same frequency.
#define LEDC_TIMER_13_BIT 13
#define LEDC_BASE_FREQ_R1 40
#define LEDC_BASE_FREQ_R2 80
#define LED_PIN_1 15 // pin for first signal
#define LED_PIN_2 26 // pin for second signal
#define LEDC_CHANNEL_0 0
#define LEDC_CHANNEL_1 2
void setup() {
pinMode(LED_PIN_1, OUTPUT); // set pin as output
pinMode(LED_PIN_2, OUTPUT); // set pin as output
ledcAttachChannel(LED_PIN_1, LEDC_BASE_FREQ_R1, LEDC_TIMER_13_BIT, LEDC_CHANNEL_0 );
ledcAttachChannel(LED_PIN_2, LEDC_BASE_FREQ_R2, LEDC_TIMER_13_BIT, LEDC_CHANNEL_1 );
// Initiates PWM signals with a 50% duty cycle
ledcWrite(LED_PIN_1, 4096); // 50% of 2^13 = 4096
ledcWrite(LED_PIN_2, 4096); // 50% of 2^13 = 4096
}
void loop() {
// The loop is kept empty or with other commands as needed
}
Suscribirse a:
Entradas (Atom)