Page 1 of 1

How to keep LEDs turn on without fading or PWM

Posted: Wed Nov 07, 2018 5:22 pm
by snahmad75
Hi,

Here is my code

Code: Select all

#define LEDC_HS_TIMER          LEDC_TIMER_0
#define LEDC_HS_MODE           LEDC_HIGH_SPEED_MODE
#define LEDC_HS_CH0_GPIO       (32)
#define LEDC_HS_CH0_CHANNEL    0

#define LEDC_HS_CH1_GPIO       (33)
#define LEDC_HS_CH1_CHANNEL    1

#define LEDC_LS_TIMER          LEDC_TIMER_1
#define LEDC_LS_MODE           LEDC_LOW_SPEED_MODE

#define LEDC_LS_CH2_GPIO       (26)
#define LEDC_LS_CH2_CHANNEL    2

#define LEDC_LS_CH3_GPIO       (0)
#define LEDC_LS_CH3_CHANNEL    3

#define LEDC_TEST_CH_NUM       (4)

ledc_timer_config_t ledc_timer;
ledc_channel_config_t ledc_channel[LEDC_TEST_CH_NUM];

/**************************************************************************//**
\brief		
\details	
*******************************************************************************/
void initLeds()
{
    /*
     * Prepare and set configuration of timers
     * that will be used by LED Controller
     */
	 
	ledc_timer.duty_resolution = LEDC_TIMER_13_BIT;
    ledc_timer.freq_hz = 5000;
    ledc_timer.speed_mode = LEDC_HS_MODE;
    ledc_timer.timer_num = LEDC_HS_TIMER;
    
    // Set configuration of timer0 for high speed channels
    ledc_timer_config(&ledc_timer);

    // Prepare and set configuration of timer1 for low speed channels
    ledc_timer.speed_mode = LEDC_LS_MODE;
    ledc_timer.timer_num = LEDC_LS_TIMER;
    ledc_timer_config(&ledc_timer);
	
	ledc_channel[0].channel    = (ledc_channel_t)LEDC_HS_CH0_CHANNEL;
    ledc_channel[0].duty       = 4000;
    ledc_channel[0].gpio_num   = LEDC_HS_CH0_GPIO;
    ledc_channel[0].speed_mode = LEDC_HS_MODE;
    ledc_channel[0].timer_sel  = LEDC_HS_TIMER;
	ledc_channel[0].intr_type  = LEDC_INTR_DISABLE;

	ledc_channel[1].channel    = (ledc_channel_t)LEDC_HS_CH1_CHANNEL;
    ledc_channel[1].duty       = 4000;
    ledc_channel[1].gpio_num   = LEDC_HS_CH1_GPIO;
    ledc_channel[1].speed_mode = LEDC_HS_MODE;
    ledc_channel[1].timer_sel  = LEDC_HS_TIMER;
	ledc_channel[1].intr_type  = LEDC_INTR_DISABLE;
 
    ledc_channel[2].channel    = (ledc_channel_t)LEDC_LS_CH2_CHANNEL;
    ledc_channel[2].duty       = 4000;
    ledc_channel[2].gpio_num   = LEDC_LS_CH2_GPIO;
    ledc_channel[2].speed_mode = LEDC_HS_MODE;
    ledc_channel[2].timer_sel  = LEDC_HS_TIMER;
	ledc_channel[2].intr_type  = LEDC_INTR_DISABLE;
        
	ledc_channel[3].channel    = (ledc_channel_t)LEDC_LS_CH3_CHANNEL;
    ledc_channel[3].duty       = 4000;
    ledc_channel[3].gpio_num   = LEDC_LS_CH3_GPIO;
    ledc_channel[3].speed_mode = LEDC_LS_MODE;
    ledc_channel[3].timer_sel  = LEDC_LS_TIMER;
	ledc_channel[3].intr_type  = LEDC_INTR_DISABLE;
	

    // Set LED Controller with previously prepared configuration
    for (int ch = 0; ch < LEDC_TEST_CH_NUM; ch++) {
	    ledc_channel_config(&ledc_channel[ch]);
    }

    // Initialize fade service.
    ledc_fade_func_install(0);

Thanks,
Naem

Re: How to keep LEDs turn on without fading or PWM

Posted: Wed Nov 07, 2018 7:39 pm
by snahmad75
Can some one reply please.

I need to keep my leds on all the time.

Re: How to keep LEDs turn on without fading or PWM

Posted: Thu Nov 08, 2018 2:58 am
by ESP_Sprite
...if you need to keep your leds on all the time, why use the LED PWM unit? Just set the GPIO high and you're there.

Re: How to keep LEDs turn on without fading or PWM

Posted: Thu Nov 08, 2018 3:36 am
by WiFive
:idea:

Re: How to keep LEDs turn on without fading or PWM

Posted: Thu Nov 08, 2018 9:37 am
by snahmad75
ESP_Sprite wrote:...if you need to keep your leds on all the time, why use the LED PWM unit? Just set the GPIO high and you're there.
Kindly give example of setting Led GPIO to high

Re: How to keep LEDs turn on without fading or PWM

Posted: Thu Nov 08, 2018 9:43 am
by chegewara

Re: How to keep LEDs turn on without fading or PWM

Posted: Thu Nov 08, 2018 11:25 am
by snahmad75

Thanks, I will try this set it high using GPIO number of led.

Re: How to keep LEDs turn on without fading or PWM

Posted: Fri Nov 09, 2018 7:45 am
by Ritesh
snahmad75 wrote:

Thanks, I will try this set it high using GPIO number of led.
Hi,

You just need to set direction of thst GPIO and then set value to High to keep LED as solid ON.

No more configuration is required for that.

Re: How to keep LEDs turn on without fading or PWM

Posted: Fri Nov 09, 2018 2:55 pm
by snahmad75
Thanks everyone. all working.

Re: How to keep LEDs turn on without fading or PWM

Posted: Fri Nov 09, 2018 3:08 pm
by Ritesh
snahmad75 wrote:
Fri Nov 09, 2018 2:55 pm
Thanks everyone. all working.
Great. Thanks for update regarding same.