BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Robotic Arm Project:The Sage Continues (again)

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();
}


3 posts were merged into an existing topic: Help with robotic arm project