AUTOFOKUS
Published

Drawing Robot

A robot arm moved using servo motors.

IntermediateFull instructions provided2,445
Drawing Robot

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
Move arm z axes
×2
Rotary potentiometer (generic)
Rotary potentiometer (generic)
2 pot's to control arm
×2
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
Button to fix the pos of arm
×1
Arduino Mega 2560
Arduino Mega 2560
Arduino MEGA 2560 to control the arm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schematics

Fritzing schematics

schematics image

Code

Calibrating code

C/C++
Code for getting servo pos values
#include <Servo.h>
Servo first;//first arm segment
Servo second;//second arm segment

//pots for controling the arm
int firstpot = A8;
int secondpot = A9;

//button to fix position
int btt = 2;

void setup() {
  pinMode(btt, INPUT); //button pinMode
  Serial.begin(9600);//start serial
  //servos
  first.attach(3);
  second.attach(4);
}

void loop() {
  first.write(map(analogRead(firstpot), 0, 1023, 50, 120)); //first servo turned by pot using map() servo protection by borders of servo turning options
  second.write(map(analogRead(secondpot), 0, 1023, 0, 100)); //second servo turned by pot using map() servo protection by borders of servo turning options
  delay(10);//delay for stability
  
  if (digitalRead(btt) == 1) {//if botton pressed
    Serial.print("first -->");
    Serial.println(map(analogRead(firstpot), 0, 1023, 50, 150));
    Serial.print("second -->");
    Serial.println(map(analogRead(secondpot), 0, 1023, 0, 100));
    delay(1000);
  }
  
}

Moving code

C/C++
When you have servo values run this code and place values there
#include <Servo.h>
Servo first;//first arm segment
Servo second;//second arm segment

void setup() {
  //servos
  first.attach(3);
  second.attach(4);
}

void loop() {
    moveHand(90,90);//insert values - (first,second)
    delay(1000);
    moveHand(120,90);
    delay(1000);
    moveHand(80,80);
    delay(1000);
}
void moveHand(int f,int s) {
  first.write(f);
  second.write(s);
}

Credits

AUTOFOKUS
0 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.