Khemiri Mahrane
/
Nucleo_PWM
ServoProg
main.cpp
- Committer:
- Mahran
- Date:
- 2016-02-09
- Revision:
- 0:bb0da30d43f4
- Child:
- 1:c56c4fb5cb59
File content as of revision 0:bb0da30d43f4:
#include "mbed.h" //TIM1_CH1 PwmOut PWM1(PA_8); //TIM1_CH4 PwmOut PWM2(PA_11); //TIM16_CH1 PwmOut PWM3(PA_12); //TIM3_CH1 PwmOut PWM4(PB_0); //TIM3_CH4 PwmOut PWM5(PB_7); //TIM17_CH1N PwmOut PWM6(PB_6); //TIM3_CH4, PwmOut PWM7(PB_1); //TIM3_CH3 PwmOut PWM8(PB_0); float map (int x, int in_min,int in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } void Pince_Bas_Gauche(int a) { PWM1.period_ms(20); PWM1.write(map (a,0,180,0.028f,0.12f)); } void Pince_Bas_Droite(int a) { PWM2.period_ms(20); PWM2.write(map (a,0,180,0.028f,0.12f)); } void Pince_Glissement_Gauche(int a) { PWM3.period_ms(20); PWM3.write(map (a,0,180,0.028f,0.12f)); } void Pince_Glissement_Droit(int a) { PWM4.period_ms(20); PWM4.write(map (a,0,180,0.028f,0.12f)); } int main() { while(1) { } }