This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PWM control using accelerometer

hello friends,

i need to control 4 LED brightness using PWM according to accelerometer values. how can i do that

i am using SDK11, nrf52832, KEIL MDK5

i going to attach main file what i am doing wrong please check and let me know main.txt

and if possible please let know how can i proceed in right way

Parents
  • Hi,

    What kind of issues do you have ?

    I see that you are setting the duty cycle to the same value 100 times in a row. That should not be necessary, E.g:

    			    if(accel_values.x > 8000 && accel_values.x < 10000)
    				{
    					for(int i = 0; i <= 100; i++)
    					{
    						pwm_update_duty_cycle(25);
    					}
    				}
    

    So remove these for(int i = 0; i <= 100; i++) loops, .i.e to

    				if(accel_values.x > 8000 && accel_values.x < 10000)
    				{
    							
    							pwm_update_duty_cycle(25);
    				}
    
Reply
  • Hi,

    What kind of issues do you have ?

    I see that you are setting the duty cycle to the same value 100 times in a row. That should not be necessary, E.g:

    			    if(accel_values.x > 8000 && accel_values.x < 10000)
    				{
    					for(int i = 0; i <= 100; i++)
    					{
    						pwm_update_duty_cycle(25);
    					}
    				}
    

    So remove these for(int i = 0; i <= 100; i++) loops, .i.e to

    				if(accel_values.x > 8000 && accel_values.x < 10000)
    				{
    							
    							pwm_update_duty_cycle(25);
    				}
    
Children
No Data
Related