Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
wiki:projets:robot-semi-hommeinmoov [2015/06/29 16:53] EMMANUEL Laurent |
wiki:projets:robot-semi-hommeinmoov [2020/10/05 14:39] (Version actuelle) |
||
---|---|---|---|
Ligne 235: | Ligne 235: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | 03/07/2015 : \\ | ||
+ | code pour le servo qui fait hocher la tête. \\ | ||
+ | < | ||
+ | #include < | ||
+ | |||
+ | Servo myservo; | ||
+ | |||
+ | int Min = 20; | ||
+ | int Max = 180; | ||
+ | |||
+ | |||
+ | int pos = 0; // variable to store the servo position | ||
+ | int vitesse=15; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | pinMode(6, | ||
+ | myservo.attach(6); | ||
+ | | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | // | ||
+ | |||
+ | |||
+ | |||
+ | for(pos = Min; pos < Max; pos += 1) // goes from 0 degrees to 180 degrees | ||
+ | { // in steps of 1 degree | ||
+ | myservo.write(pos); | ||
+ | delay(vitesse); | ||
+ | } | ||
+ | |||
+ | | ||
+ | { | ||
+ | myservo.write(pos); | ||
+ | | ||
+ | delay(vitesse); | ||
+ | } | ||
+ | |||
+ | delay(1500); | ||
+ | | ||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Tout les moteurs des bras sont asservis, voici le code qui permet de controler le robot avec leur extreneum : | ||
+ | < | ||
+ | #include < | ||
+ | |||
+ | //partie gauche | ||
+ | Servo g_aisselle; | ||
+ | Servo g_homoplate; | ||
+ | Servo g_rotbras; | ||
+ | Servo g_contraction; | ||
+ | |||
+ | // | ||
+ | Servo d_aisselle; | ||
+ | Servo d_homoplate; | ||
+ | Servo d_rotbras; | ||
+ | Servo d_contraction; | ||
+ | |||
+ | int mini = 0; // variable to store the servo position | ||
+ | int maxi = 180 ; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | g_aisselle.attach(2); | ||
+ | g_homoplate.attach(3); | ||
+ | g_rotbras.attach(4); | ||
+ | g_contraction.attach(5); | ||
+ | | ||
+ | d_aisselle.attach(9); | ||
+ | d_homoplate.attach(10); | ||
+ | d_rotbras.attach(11); | ||
+ | d_contraction.attach(12); | ||
+ | |||
+ | // attaches the servo on pin 9 to the servo object | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | /* | ||
+ | for(mini = 0; mini < 180; mini += 1) // goes from 0 degrees to 180 degrees | ||
+ | { // in steps of 1 degree | ||
+ | myservo.write(mini); | ||
+ | delay(15); | ||
+ | } | ||
+ | for(maxi = 180; maxi>=1; maxi-=1) | ||
+ | { | ||
+ | myservo.write(maxi); | ||
+ | delay(15); | ||
+ | } | ||
+ | |||
+ | */ | ||
+ | // position initale | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | g_contraction.write(0); | ||
+ | | ||
+ | d_aisselle.write(50); | ||
+ | d_homoplate.write(30); | ||
+ | d_rotbras.write(100); | ||
+ | d_contraction.write(165); | ||
+ | |||
+ | //coucou | ||
+ | /* | ||
+ | d_aisselle.write(50); | ||
+ | d_homoplate.write(110); | ||
+ | |||
+ | d_contraction.write(160); | ||
+ | d_rotbras.write(150); | ||
+ | delay (3000); | ||
+ | d_rotbras.write(100); | ||
+ | delay (3000); | ||
+ | |||
+ | */ | ||
+ | |||
+ | // WTF | ||
+ | |||
+ | /* | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | d_aisselle.write(50); | ||
+ | d_homoplate.write(100); | ||
+ | d_rotbras.write(180); | ||
+ | d_contraction.write(165); | ||
+ | */ | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ |