Projet

Général

Profil

Bras Robot » Bras_Robot_Automatique.ino

Programme (Programme pour le bras exécutant les mouvements envoyés en bluetooth) - Thomas Coment, 20/11/2020 16:06

 
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;


int i = 0;

int servo1PPos, servo2PPos, servo3PPos, servo4PPos, servo5PPos, servo6PPos; // Positions initiales des servomoteurs

void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // Commande initialisant la communication série entre l'ordinateur et l'arduino

// Série de commande liant les servomoteurs aux broches de l'arduino
servo1.attach(5); // Cette commande lie le servomoteur "servo1" à la broche "5"
servo2.attach(6);
servo3.attach(7);
servo4.attach(8);
servo5.attach(9);
servo6.attach(10);

servo1.write(55);
servo2.write(120);
servo3.write(120);
servo4.write(80);
servo5.write(5);
servo6.write(80);

delay(1000);

}

void loop() {
Serial.println ("DEBUT DE PHASE 1");
for (i = 0; i < 130; i++) {
if (i <= 75)
{
servo1.write (55+(i*50/75));
servo2.write ( 120 - i );
if (i <= 30)
{
servo3.write ( 120 - i );
}
}
else
{
servo6.write ((80+75)-i);
}

delay(15);
}
Serial.println("FIN DE PHASE 1");

Serial.println("DEBUT DE PHASE 2");

for (i = 0; i <= 30; i++)
{
servo3.write(90 - i);

delay(25);
}
for (i = 0; i <= 100; i++)
{
servo1.write(105 - i);

delay(25);
}
for (i = 0; i <= 15; i++)
{
servo3.write(60 + i);

delay(25);
}
for (i = 0; i <= 55; i++)
{
servo6.write (25 + i);

delay(25);
}
Serial.println("FIN DE PHASE 2");

Serial.println("DEBUT DE PHASE 3");

for (i = 0; i <= 75; i++)
{
servo1.write (5+ ( i * 50 / 75 ));
servo2.write (45 + i);
servo3.write (75 + ( i * 45 / 75 ));
delay(25);
}

Serial.println("FIN DE PHASE 3");

}
(15-15/15)