Help with robotic arm project

Hello, I’m working on my robotic arm semester project and I want to try incorporating bluetooth as my method of control. I’m using an HM-10 module with an Arduino UNO on iOS version 13.1.3.

I’ve tried using different combos of Blynk widgets and find it difficult to be precise (it has to be able to pick up 3 different sized balls and a screw and place them in a receptacle). I want to try a combination of sliders (for large movements) and a text input (for precision).

I know that the numbers sent through the text input widget are received as a string, which should be converted to an integer. You’ll see that’s what I attempted to do for the Grip motor on (V4). The code compiles but nothing happens. Please help by taking a look at my code, also if you have any other ideas for the smoothest possible control of the robotic arm via bluetooth, let me know! I’d love some suggestions.


#define BLYNK_PRINT Serial

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
    
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
#include <Servo.h>

char auth[] = "AS_t37qM4bnXV14iMNoUSNqI4WcF_NEy";

SoftwareSerial SerialBLE(10, 11); // RX, TX

Servo Base;
Servo Shoulder;
Servo Elbow;
Servo Grip;

BLYNK_WRITE(V1)
{
  Base.write(param.asInt());
}
BLYNK_WRITE(V2)
{
  Shoulder.write(param.asInt());
}
BLYNK_WRITE(V3)
{
  Elbow.write(param.asInt());
}
BLYNK_WRITE(V4)
{
  String Gripvalue=(param.asStr());
  int Myvalue=Gripvalue.toInt();
  Grip.write(Myvalue);

}

void setup()
{
  // Debug console
  Serial.begin(9600);

  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");

  Base.attach(3);
  Shoulder.attach(5);
  Elbow.attach(6);
  Grip.attach(9);
}

void loop()
{
  Blynk.run();
}

If you are trying to use a number, why not use the numeric input widget instead?

First, this is an interesting application using Blynk. I just have some suggestions (maybe not right, as I don’t have one to test) for you to consider as follows:

  1. Use ESP8266 (integrated WiFi) so that it’s easier to use and currently more reliable than using UNO with HM-10 BlueTooth.

  2. To control that arm, you have to input / control / calculate 4 different parameters: x-y-z and grip.

    a. For x-y, you can use a joystick widget, giving you x and y that you can control Base and Elbow. From those x-y, you can add more control of Shoulder if necessary to extend the reach.

    b. For z, you can use a vertical slider, then control Shoulder to handle up - down movement of arm so that Grip can reach the object. You might have to adjust Elbow if necessary then.

    c. For Grip, you can Numeric Input, of which you can specify the step fine enough to guarantee not breaking anything.

    d. Certainly, it’s better if you have some kind of sensors to detect the grip pressure just hard enough and not to exercise more force. You might use servo current sensor, pressure sensor, etc. to do this. But it might not be in the scope of your semester project.

Good luck.

1 Like

Also @Gunner has an example using two sliders that tackles the large and precision problem.

1 Like

I like the reliability of a WiFi module however I have to demonstrate the robot’s functionality in class, which means going through the school’s unreliable guest network. Thank you for the suggestion anyways!

This might be really helpful, I’ll try this out! Thank you!

Regarding the numeric input widget, I was trying to steer clear of anything similar to the step widget as I found that for whatever reason, the grip servo in particular starts to throw a fit.

Hello again Blynkers,

If you hadn’t seen my post from yesterday, December 4th, I’m working on a robotic arm project that has to be able to pick up three different sized balls and place them in a receptacle. I’m using an Arduino Uno with an HM-10 bluetooth module on iOS 13.1.3.

Previously, I’ve tried controlling the individual motors with various Blynk widgets and simply cannot make it precise enough to the point that it’s practical. I think the next best move I can make before abandoning bluetooth all together is remove all user input to eliminate error by making it mostly autonomous.

I figured I could use potentiometers to figure out exactly how to position the motors to pick up each object, and use those position values to write functions that would perform the correct routine for each ball. Within Blynk itself I’m using a segmented switch that would let me switch between the routines.

I’ve found that having two functions back to back in a single case statement doesn’t work and it’ll only perform the first one, I assume it needs a delay of some kind to give it time to perform both? I’m not quite sure where to go about it from here. Is there a better way of doing this? Is it possible to record a run through with the potentiometers and then have a Blynk widget that can play it back? I’d love some suggestions, thank you!


#define BLYNK_PRINT Serial

#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11); // RX, TX
    
#include <BlynkSimpleSerialBLE.h>
#include <SoftwareSerial.h>
#include <Servo.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "2d7nWTQf0Efh6n13_lJ0WYfZ0JPYCVwB";

SoftwareSerial SerialBLE(10, 11); // RX, TX

Servo Base;
Servo Shoulder;
Servo Elbow;
Servo Grip;

void Receptacle()   // positions arm at receptacle
{
  Base.write(0);
  Shoulder.write(120);
  Elbow.write(95);
  Grip.write(120);
}
void Stage()      // positions arm at pickup stage
{ Base.write(90);
  Shoulder.write(120);
  Elbow.write(95);
  Grip.write(50);
}
void BigBall()   //routine for picking up big ball
{} 
void SmallBall()  //routine for picking up small ball
{}
void Marble()   //routine for picking up marble
{}

BLYNK_WRITE(V1)
{

switch (param.asInt())
  {
    case 1: 
      { 
       Stage();
       BigBall();
       Receptacle();
          break;
       }
    case 2: 
    { 
     Stage();
     SmallBall();
     Receptacle();
      break;
    }
    case 3: 
    { 
      Stage();
      Marble();
      Receptacle();
      break;
      }
    }
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  SerialBLE.begin(9600);
  Blynk.begin(SerialBLE, auth);

  Serial.println("Waiting for connections...");

  Base.attach(3);
  Shoulder.attach(5);
  Elbow.attach(6);
  Grip.attach(9);
}

void loop()
{
  Blynk.run();
}


Maybe each switch segment could be a function/position. Then just push them next one once the other one finishes.

for example:

switch (param.asInt())
  {
    case 1: 
      { 
       Stage();
       break;
       }
    case 2: 
    { 
     Receptacle();
      break;
    }
    case 3: 
    { 
      Marble();
      break;
      }
 case 4: 
    { 
      SmallBall();
      break;
      }
 case 5: 
    { 
     BigBall();
      break;
      }
    }
1 Like

This is probably a cleaner approach, I’ll definitely consider going about it this way instead. Thanks for helping me again!

I’ve moved your newly created topic into your previous one, as they are about the same thing.

You should sort-out your SoftwareSerial code.
You’re including the library twice, which is unnecessary, then creating two different SoftwareSerial ports using the same pins, although the SwSerial port is never used once it’s been created, so should be deleted.

Pete.