Control LittleArm Arduino Robot with Windows Application

Control LittleArm Arduino Robot with Windows Application © CC BY

Use a USB serial connection and our Desktop App to control the LittleArm Arduino robot arm.

  • 3,184 views
  • 1 comment
  • 15 respects

Components and supplies

Necessary tools and machines

3drag
3D Printer (generic)

About this project

Introduction

We have been posting about the LittleArm for quite awhile. But we haven't posted a tutorial about using the original Desktop Software. Well, we recently released a new version of the software that is awesome, so we thought we ought to create a quick tutorial about it. So here you go.

What is LittleArm

The LittleArm was originally designed to be controlled entirely via USB. We have started moving away from that because it limits the arm, being connected by a USB cord. But the Desktop app gives a lot more functionality than the Android App.

Using the app you can record sequences, save them as a .txt file, and play them back later. The App was written in Python and then we use Pyinstaller to turn it into a single-file windows executable. You can download the desktop app here. Here is the video of how to use the App.

Training the LittleArm with the app.

The App

If you just finished that video and you have downloaded the app, you will notice some differences. Here is what the app looks like now:

As you can see the new app is a lot cleaner and offers more functionality. The Looping buttons allow you to play a sequence forever. Also, the file menu allows for the saving and opening of new sequences. We would like to see folks start sharing these sequences so that other people can replicate them, just by downloading the .txt file.

Connecting to Arduino

The other big change is that the App does not auto-connect to the Arduino. We changed this because the various Arduino clones out there have different USB names. So we decided it was easier to to just have users select the port the Arduino is connected to at start-up instead of having the software do the thinking.

You do have to configure the LittleArm differently for the Desktop connection. This is mainly to prevent voltage overloads through the USB port. Just use the wiring diagram below to get started. If you purchase the LittleArm kit, this diagram comes standard in the box:

That is pretty much it. Download the app, plug in the Arduino, and start playing with it. Enjoy!

Code

Standard Littlearm Arduino SketchArduino
#include <Servo.h>  //arduino library
#include <math.h>   //standard c library

#define PI 3.141

Servo baseServo;  
Servo shoulderServo;  
Servo elbowServo; 
Servo gripperServo;

int command;

struct jointAngle{
  int base;
  int shoulder;
  int elbow;
};

int desiredGrip;
int gripperPos;

int desiredDelay;

int servoSpeed = 15;
int ready = 0;

struct jointAngle desiredAngle; //desired angles of the servos

//+++++++++++++++FUNCTION DECLARATIONS+++++++++++++++++++++++++++

int servoParallelControl (int thePos, Servo theServo );
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

void setup()
{ 
  Serial.begin(9600);
  baseServo.attach(9);        // attaches the servo on pin 9 to the servo object 
  shoulderServo.attach(10);
  elbowServo.attach(11);
  gripperServo.attach(6);
  
  Serial.setTimeout(50);      //ensures the the arduino does not read serial for too long
  Serial.println("started");
  baseServo.write(90);        //intial positions of servos
  shoulderServo.write(150);
  elbowServo.write(110);
  ready = 0;
} 

//primary arduino loop
void loop() 
{ 
  if (Serial.available()){
    ready = 1;
    desiredAngle.base = Serial.parseInt();
    desiredAngle.shoulder = Serial.parseInt();
    desiredAngle.elbow = Serial.parseInt();
    desiredGrip = Serial.parseInt();
    desiredDelay = Serial.parseInt();

    if(Serial.read() == '\n'){               // if the last byte is 'd' then stop reading and execute command 'd' stands for 'done'

        Serial.flush();                     //clear all other commands piled in the buffer
          //send completion of the command
        Serial.print('d');      
    }
  }
  
  int status1 = 0;
  int status2 = 0;
  int status3 = 0;
  int status4 = 0;
  int done = 0 ; 
  
  while(done == 0 && ready == 1){  
    //move the servo to the desired position
    status1 = servoParallelControl(desiredAngle.base, baseServo, desiredDelay);
    status2 = servoParallelControl(desiredAngle.shoulder,  shoulderServo, desiredDelay);
    status3 = servoParallelControl(desiredAngle.elbow, elbowServo, desiredDelay);      
    status4 = servoParallelControl(desiredGrip, gripperServo, desiredDelay);  
    
    if (status1 == 1 & status2 == 1 & status3 == 1 & status4 == 1){
      done = 1;
      
    }
        
  }// end of while
  

  
  
}

//++++++++++++++++++++++++++++++FUNCTION DEFITNITIONS++++++++++++++++++++++++++++++++++++++++++

int servoParallelControl (int thePos, Servo theServo, int theSpeed ){
  
    int startPos = theServo.read();        //read the current pos
    int newPos = startPos;
    //int theSpeed = speed;
    
    //define where the pos is with respect to the command
    // if the current position is less that the actual move up
    if (startPos < (thePos-5)){
          
       newPos = newPos + 1;
       theServo.write(newPos);
       delay(theSpeed);
       return 0;
           
    }
  
   else if (newPos > (thePos + 5)){
  
      newPos = newPos - 1;
      theServo.write(newPos);
      delay(theSpeed);
      return 0;
          
    }  
    
    else {
        return 1;
    }  
    
  
}

Schematics

Standard USB wiring diagram
Yvclxywdminkdg1fyhe4

Comments

Similar projects you might like

Littlearm 2C: Build a 3D Printed Arduino Robot Arm

Project tutorial by Slant Concepts

  • 4,404 views
  • 1 comment
  • 32 respects

"Waldo" Motion Capture with LittleArm

Project showcase by Slant Concepts

  • 3,975 views
  • 3 comments
  • 31 respects

Control Arduino Robot Arm with Android App

Project tutorial by Slant Concepts

  • 9,001 views
  • 7 comments
  • 26 respects

LittleArm: Arduino Robot Arm

Project showcase by Slant Concepts

  • 17,219 views
  • 2 comments
  • 76 respects

MyRobot - Made To Control A Whole Robot

by Tiago Alves

  • 4,896 views
  • 1 comment
  • 17 respects

Control Arduino LittleArm with Ultrasonic Sensor

Project showcase by Slant Concepts

  • 3,678 views
  • 0 comments
  • 7 respects
Add projectSign up / Login