How to keep LEDs turn on without fading or PWM

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

How to keep LEDs turn on without fading or PWM

Postby snahmad75 » Wed Nov 07, 2018 5:22 pm

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

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Wed Nov 07, 2018 7:39 pm

Can some one reply please.

I need to keep my leds on all the time.

ESP_Sprite
Posts: 8884
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Thu Nov 08, 2018 2:58 am

...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.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

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

Postby WiFive » Thu Nov 08, 2018 3:36 am

:idea:

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Thu Nov 08, 2018 9:37 am

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


snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Thu Nov 08, 2018 11:25 am


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

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

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

Postby Ritesh » Fri Nov 09, 2018 7:45 am

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.
Regards,
Ritesh Prajapati

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Fri Nov 09, 2018 2:55 pm

Thanks everyone. all working.

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

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

Postby Ritesh » Fri Nov 09, 2018 3:08 pm

snahmad75 wrote:
Fri Nov 09, 2018 2:55 pm
Thanks everyone. all working.
Great. Thanks for update regarding same.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 84 guests