How to deconstruct GCodes to control my robotic arm?

Hello Everyone!

I build a simple robotic arm with Arduino and servo motors.

It can make simple movement. For example it can make dots or draw arc. But all these movements are predefined by me. I defined the movements as degree of servo and I m sending servo positions to move robotic arm move. This is so limited. I m wanting to send coordinates, Arduino can calculate servos’ positions.

I can control robotic arm with sending servo degrees( with PWN values ).
I m wanting control robotic arm with sendind coordinates or GCodes.
How can deconstruct GCodes ( or coordinates ) to servo degrees?

After that, my robotic arm can draw shapes, write to paper or print objects !

The only way I can image is setting up a stereo came system and mapping all positions - servo degrees equations. So I will have all servo positions data for specific coordinates and I will know servos positions for all coordinates.

Is there any shorter way? A free&basic simulator program or a mathematical way or anything else ?

My code is really simple. I m sharing it.
Also I added robotic arms images.

Any help will be appreciated !

#include <Servo.h>

Servo x1Axis;
Servo y1Axis;
Servo y2Axis;

int pos = 0;   

// each NOTA variable keeps 3 servos' postions.  

struct NOTA {
    int x1;
    int y1;
    int y2;

// I m sending these variables to notaHareketi function to make movements.
// These values represent servos' positions.

NOTA doBas = { 50, 50, 10 };
NOTA doSal = { 50, 70, 10 };

NOTA reBas = { 80, 50, 14 };
NOTA reSal = { 80, 70, 14 };

NOTA miBas = { 100, 50, 18 };
NOTA miSal = { 100, 70, 18 };

void setup() {
void loop() {



void notaHareketi(NOTA nota){


What you want is called "inverse kinematics", which involves having a mathematical model for the lengths and joints of the arm.

Your program will then take the desired final position and orientation of the "gripper" (if there is one) and calculate the best arm movements to achieve that goal, taking into account mechanically forbidden angles, obstructions, etc.

It is not at all a simple problem, but Google will provide plenty of information.