×

Xpander Robot : Explorer & Claw

Servo Wrist

Pergelangan servo/ wrist sama seperti pengaturan Servo Gripper, dimana pergerakkannya lebih besar, karena menggerakkan pergelanggan gripper agar dapat memalingkan ke kiri dan kanan. Pasang pin Servo Wrist pada Servo 2 – label di Motor Shield (Pin 9 Digital Arduino). Perhatikan script Arduino dibawah ini :

/*
 * Bas on Tech - SG90 tower pro servo
 *
 * This course is part of the courses on https://arduino-tutorials.net
 *  
 * (c) Copyright 2019 - Bas van Dijk / Bas on Tech
 * This code and course is copyrighted. It is not allowed to use these courses commercially
 * without explicit written approval
 * 
 * YouTube:    https://www.youtube.com/c/BasOnTech
 * Facebook:   https://www.facebook.com/BasOnTechChannel
 * Instagram:  https://www.instagram.com/BasOnTech
 * Twitter:    https://twitter.com/BasOnTech
 *
 * Servo specifications https://servodatabase.com/servo/towerpro/sg90
 * 
 * Brown  -> GND
 * Red    -> 5V
 * Orange -> A8
 * 
 */

#include <Servo.h>    // Import the Servo library to control the servo

Servo servo;          // Initialise the servo object to control the servo

int pos = 10;         // variable for the position of the servo

void setup() {
  servo.attach(9);    // Tell the servo object that we've connected to pin 9
  servo.write(0);     // Helps to adjust the initial position
  delay(40);  
}

void loop() {
  
  // Make the pos variabele go from 0 to 90
  for (pos = 0; pos <= 90; pos++) {
    servo.write(pos);  // Set the position of the servo
    delay(10);         // Wait for 10ms for the servo to process the command
  }

  // Make the pos variabele go from 90 to 0
  for (pos = 90; pos >= 0; pos--) {
    servo.write(pos);  // Set the position of the servo
    delay(10);         // Wait for 10ms for the servo to process the command
  }
 
}

Baik uji coba Servo Gripper maupun Servo Wrist, kita sebaiknya belum menghubungkan servo motor dengan mekanik, agar kita dapat mendapatkan gambaran lebar sapuan dari servo, sehingga menghindari kerusakan mekanik maupun gearbox servo itu sendiri akibat salah pemberian value servo terlalu besar/ kecil.

Setelah digabungkan, kita dapat menggerakkan kedua Servo diatas secara bersama-sama, dengan script Arduino sebagai berikut :

/*
 * Bas on Tech - SG90 tower pro servo
 *
 * This course is part of the courses on https://arduino-tutorials.net
 *  
 * (c) Copyright 2019 - Bas van Dijk / Bas on Tech
 * This code and course is copyrighted. It is not allowed to use these courses commercially
 * without explicit written approval
 * 
 * YouTube:    https://www.youtube.com/c/BasOnTech
 * Facebook:   https://www.facebook.com/BasOnTechChannel
 * Instagram:  https://www.instagram.com/BasOnTech
 * Twitter:    https://twitter.com/BasOnTech
 *
 * Servo specifications https://servodatabase.com/servo/towerpro/sg90
 * 
 * Brown  -> GND
 * Red    -> 5V
 * Orange -> A8
 * 
 */

#include <Servo.h>    // Import the Servo library to control the servo

Servo servoGripper;          // Initialise the servo object to control the servo
Servo servoWrist;          // Initialise the servo object to control the servo

int pos = 10 ;         // variable for the position of the servo

void setup() {
  servoGripper.attach(9);    // Tell the servo object that we've connected to pin 8
  servoGripper.write(0);     // Helps to adjust the initial position
  servoWrist.attach(10);    // Tell the servo object that we've connected to pin 8
  servoWrist.write(0);     // Helps to adjust the initial position
  delay(40);  
}

void loop() {
  
  // Make the pos variabele go from 0 to 180
  for (pos = 0; pos <= 75; pos++) {
    servoGripper.write(pos);  // Set the position of the servo
    servoWrist.write(pos+15);
    delay(50);         // Wait for 10ms for the servo to process the command
  }
 
  // Make the pos variabele go from 180 to 0
  for (pos = 75; pos >= 0; pos--) {
    servoGripper.write(pos);  // Set the position of the servo
    servoWrist.write(pos-15);
    delay(50);         // Wait for 10ms for the servo to process the command
  }
}

Pages: 1 2 3 4 5