AhmedAzouz
Published © LGPL

UR12 Musician & Assistant Robotic Arm

A desktop-sized miniature robot arm capable of performing work accurately by mouse operation, serving tea, and playing music.

IntermediateProtip15 hours2,936
UR12 Musician & Assistant Robotic Arm

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Arduino sensor shield V5
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
MG955 Metal gear servo
×3

Software apps and online services

Processing
The Processing Foundation Processing
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Code

Processing 3 Code

Processing
//Processing code:

import processing.serial.*;      

int xpos=90; // set x servo's value to mid point (0-180);
int ypos=90; // and the same here
Serial port; // The serial port we will be using</p><p>void setup()
{
  size(360, 360);
  frameRate(100);
  println(Serial.list()); // List COM-ports
  //select second com-port from the list (COM3 for my device)
  // You will want to change the [1] to select the correct device
  // Remember the list starts at [0] for the first option.
  port = new Serial(this, Serial.list()[0], 19200);
}

void draw()
{
  fill(175);
  rect(0,0,360,360);
  fill(255,0,0); //rgb value so RED
  rect(180, 175, mouseX-180, 10); //xpos, ypos, width, height
  fill(0,255,0); // and GREEN
  rect(175, 180, 10, mouseY-180);
  update(mouseX, mouseY);
}

void update(int x, int y)
{
  //Calculate servo postion from mouseX
  xpos= x/2;
  ypos = y/2;
  //Output the servo position ( from 0 to 180)
  port.write(xpos+"x");
  port.write(ypos+"y");
}

Arduino Code

Arduino
Control the robotic arm using mouse
#include Servo.h

Servo yservo;  Servo xservo; // servos for x and y</p><p>int ypos = 0;
int xpos= 0;

void setup(){
  xservo.attach(8); //(analog pin 0) for the x servo
  yservo.attach(9);  //(analog pin 1) for the y server
 
  Serial.begin(19200); // 19200 is the rate of communication
 
}

void loop() {
  static int v = 0; // value to be sent to the servo (0-180)
  if ( Serial.available()) {
    char ch = Serial.read(); // read in a character from the serial port and assign to ch
    switch(ch) { // switch based on the value of ch
      case '0'...'9': // if it's numeric
        v = v * 10 + ch - '0';
        break;
      case 'x': // if it's x
        xservo.write(v);
        v = 0;
        break;
      case 'y':
        yservo.write(v);
        v = 0;
        break;
    }
  }
}

Credits

AhmedAzouz

AhmedAzouz

10 projects • 155 followers
High qualified software engineer, Creativity and Technology have always been a big part of my life.

Comments