G15 Cube Servo Orientation

LINIX Brushless, VEXTA Brushless, RC Servo, DC Geared, Linear, Stepper, Tamiya.....

G15 Cube Servo Orientation

Postby afz2004 » Fri Oct 21, 2016 11:59 am

Hello guys, I want to ask something. I little bit confused and kinda lost too about how I am going to set the servo. I have 3 G15 Servo Motor. Basically, first motor say it will move 30 degree CW, second motor, 50 degree CCW, and last 20 degree CW.The question, how I able to control the direction while limiting the angle number?I know in coding, I have to set 3 different ID. How bout baud rate, can all be the same? Here I attach preview of the code:

CODE: SELECT_ALL_CODE
#include <SoftwareSerial.h>
#include <Cytron_G15Shield.h>

#define G15_1 26 //Cube Servo ID

Cytron_G15Shield g15(8); // HardwareSerial + Control pin

void setup()
{
    Serial3.begin(19200);
    Serial.begin(9600);   
    g15.begin(115200);
    g15.exitWheelMode(G15_1);
    //pinMode(9,OUTPUT);
}

void loop() {
 
  int val;
  int prevVal;
  char gov;
  int hoho=0;

   if (Serial3.available())   
   {
      val=Serial3.parseInt();

      if(val>30 && val<70)
      {
        hoho=70;
      }
      else if (val>5 && val<30)
      {
        hoho=80;
      }

      switch(hoho)
      {
        case 70:
        {
        g15.setLED(G15_1, ON);
        delay(10);
        g15.setLED(G15_1, OFF);
        g15.setSpeed(G15_1, 100);
        g15.setWheelMode(G15_1,100,CCW);
        g15.setPosAngle(G15_1, 90); // Set G15 (ID = 1) position to 90 deg 
        }
        break;
       
        case 80:
        {
        g15.setLED(G15_1, ON);
        delay(10);
        g15.setLED(G15_1, OFF);
        g15.setSpeed(G15_1, 100);
        g15.setPosAngle(G15_1, 180); // Set G15 (ID = 1) position to 90 deg 
        }
        break;
       
        default:
        g15.setLED(G15_1, ON);
        delay(300);
        g15.setLED(G15_1, OFF);
        g15.setSpeed(G15_1, 200);
        g15.setPosAngle(G15_1, 0); // Set G15 (ID = 1) position to 90 deg 
      }
   }
}



p/s: code above is not picture the exact operation. for reference.
afz2004
Newbie
 
Posts: 9
Joined: Sun Jan 16, 2011 7:31 pm

Return to DC Motor

Who is online

Users browsing this forum: No registered users and 4 guests

cron