Mostrando entradas con la etiqueta two frecuencies. Mostrar todas las entradas
Mostrando entradas con la etiqueta two frecuencies. Mostrar todas las entradas

jueves, 25 de julio de 2024

Generar dos señales de reloj con la ESP32

En los canales se usa el canal cero y el canal dos porque aparentemente los canales vienen en pares y si se usa el cero y el uno tendrán la misma frecuencia.

#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
}