wassim boumaiza
/
Nucleo_PWM
servo
Fork of Nucleo_PWM by
Diff: main.cpp
- Revision:
- 1:6c59c6871460
- Parent:
- 0:bb0da30d43f4
- Child:
- 2:197217bf7bca
--- a/main.cpp Tue Feb 09 13:08:49 2016 +0000 +++ b/main.cpp Tue Feb 09 15:44:08 2016 +0000 @@ -1,7 +1,7 @@ #include "mbed.h" -//TIM1_CH1 +//TIM1_CH1 //Pince Bas gauche PwmOut PWM1(PA_8); -//TIM1_CH4 +//TIM1_CH4 //Pince bas droite PwmOut PWM2(PA_11); //TIM16_CH1 PwmOut PWM3(PA_12); @@ -22,33 +22,58 @@ } void Pince_Bas_Gauche(int a) -{ +{// 40 ouverture 0 fermeture PWM1.period_ms(20); PWM1.write(map (a,0,180,0.028f,0.12f)); } void Pince_Bas_Droite(int a) -{ +{// 0 ouverture 40 fermeture PWM2.period_ms(20); PWM2.write(map (a,0,180,0.028f,0.12f)); } - +void ouverture() +{ + Pince_Bas_Droite(0); + Pince_Bas_Gauche(40); + } +void fermeture() +{ + Pince_Bas_Droite(35); + Pince_Bas_Gauche(5); + } void Pince_Glissement_Gauche(int a) -{ +{//50avant 0 arriere PWM3.period_ms(20); PWM3.write(map (a,0,180,0.028f,0.12f)); } void Pince_Glissement_Droit(int a) -{ +{//0 avant 50 arriere PWM4.period_ms(20); PWM4.write(map (a,0,180,0.028f,0.12f)); } - +void Pince_avant() +{ +Pince_Glissement_Droit(0); +Pince_Glissement_Gauche(50); +} +void Pince_arriere() +{ +Pince_Glissement_Droit(50); +Pince_Glissement_Gauche(0); +} int main() { + while(1) { - - } +Pince_arriere(); +wait(1); +ouverture(); +wait(2); +fermeture(); +wait(2); +Pince_avant(); +wait(3); } }