cancel
Showing results for 
Search instead for 
Did you mean: 

Input: Read RC signal to Ouput: ON/OFF led

ManhPham
Associate II

Hi, I read input PWM signal from RC radiolink (done): duty_cycle range 675-1347

And now I want to convert this signal to analog to ON/OFF led, I used MAP funtions and I don't know how to move read_RC to ON led, something's like analogWrite (read_RC, Led);

 

uint32_t frequency, duty_cycle;

uint32_t capture_value;

uint32_t duty_cycle_min = 675;

uint32_t duty_cycle_max = 1347;

uint32_t read_RC;

 

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)

{

if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1)

{

capture_value = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1);

if(capture_value)

{

frequency = SystemCoreClock/(capture_value);

duty_cycle = 10000 * HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_2)/capture_value;

}

}

}

while (1)

{

read_RC = MAP(duty_cycle, duty_cycle_min, duty_cycle_max, 0, 4294967295);

}

0 REPLIES 0