Bras robotique

De Wiki LOGre
Aller à la navigation Aller à la recherche


Projet réalisé par : Jody et Benj.

Le bras robotique est un bras MeArm que l'on trouve sur internet.


Les fichiers .dxf sont trouvable sur thingiverse : MeArm.

Matériel

  • 1x kit MeArm.
  • 4x Servomoteur 9g.
  • 10x écrou M3.
  • 6x vis M3x6.
  • 15x vis M3x8.
  • 3x vis M3x10.
  • 8x vis M3x12.
  • 4x vis M3x20.

Instruction de montage

Les instructions de montage se trouvent sur le site MeArm : ici.

Electronique

TBC

Code

Code is a V0.0Beta :-P, it needs to be cleaned, reviewed and improved.

<syntaxhighlight>

  1. include <Servo.h>

const int servoP = 6; // first servo pince const int servoB2 = 9; // second servo bras 2 const int servoT = 10; // second servo tourelle const int servoB1 = 11; // second servo bras 1 const int joyX = 0; // L/R Parallax Thumbstick const int joyY = 1; // U/D Parallax Thumbstick const int joyZ = 2;

int angleX = 90;
int angleY = 90;
int angleZ = 90;

int servoVal; // variable to read the value from the analog pin

Servo myservoP; // create servo object to control a servo Servo myservoB2; // create servo object to control a servo Servo myservoT; // create servo object to control a servo Servo myservoB1; // create servo object to control a servo


void setup() {

 // Servo  
 myservoP.attach(servoP);  // attaches the servo
 myservoB2.attach(servoB2);  // attaches the servo
 myservoT.attach(servoT);  // attaches the servo
 myservoB1.attach(servoB1);  // attaches the servo


 // Inizialize Serial
 Serial.begin(9600);

}


void loop(){


   // Read the X joystick value  (value between 0 and 1023)
   servoVal = analogRead(joyX);
   if (servoVal <= 256 ) {
          angleX-- ; 
            
   } else if (servoVal >= 768 ) {
          angleX++ ;      
   } else {
                    
   }
   if (angleX > 180) {
     angleX = 180 ; 
   }
   if (angleX < 0) {
     angleX = 0 ; 
   }    
   myservoT.write(angleX);                         // sets the servo position according to the scaled value    
   // Read the Y joystick value  (value between 0 and 1023)
   servoVal = analogRead(joyY);           
   if (servoVal <= 256 ) {
          angleY-- ; 
            
   } else if (servoVal >= 768 ) {
          angleY++ ;      
   } else {
                    
   }
   if (angleY > 180) {
     angleY = 180 ; 
   }
   if (angleY < 0) {
     angleY = 0 ; 
   }  
   myservoB1.write(angleY);                           // sets the servo position according to the scaled value


// Read the Y joystick value  (value between 0 and 1023)
   servoVal = analogRead(joyZ);           
   if (servoVal <= 256 ) {
          angleZ-- ; 
            
   } else if (servoVal >= 768 ) {
          angleZ++ ;      
   } else {
                    
   }
   if (angleZ > 180) {
     angleZ = 180 ; 
   }
   if (angleZ < 0) {
     angleZ = 0 ; 
   }  
   myservoB2.write(angleZ);                           // sets the servo position according to the scaled value



   // Read the Z aka pince button joystick value  (value between 0 and 1023)
   servoVal = digitalRead(joyZ);  
            
 
   if (servoVal == 1) {
          myservoP.write(115);    
   } else {
           myservoP.write(70);    
   }
                          // sets the servo position according to the scaled value


 Serial.println(servoVal);
   // Read
   delay(5);                                       // waits for the servo to get there

}


/**

  • Display joystick values
  • /

void outputJoystick(){

   Serial.print(analogRead(joyX));
   Serial.print ("---"); 
   Serial.print(analogRead(joyY));
   Serial.print ("---"); 
   Serial.print(analogRead(joyZ));
   Serial.println ("----------------");

}

</syntaxhighlight>