How to add my G-code to .ino to run on my v-plotter?

Hi guys, I have a hanging v-plotter with Uno R3 and Sensor shield 5.0, plugged to pc, any ideas how to implement this G-code to .ino file ?

G28
M0
G0 X78.929 Y0.000
M280 P0 S30 T50
G1 X-30.342 Y195.966 F7500.0
G1 X-22.507 Y73.441 F7500.0
G1 X72.194 Y-168.443 F7500.0
G1 X-111.742 Y-136.567 F7500.0
G1 X135.596 Y117.263 F7500.0
G1 X-140.407 Y180.513 F7500.0
G1 X125.497 Y-49.614 F7500.0
G1 X-92.962 Y-199.106 F7500.0
G1 X47.370 Y-25.004 F7500.0
G1 X4.874 Y189.736 F7500.0
G1 X-56.434 Y96.110 F7500.0
G1 X100.068 Y-153.717 F7500.0
G1 X-129.648 Y-153.717 F7500.0
G1 X141.019 Y96.110 F7500.0
G1 X-132.584 Y189.736 F7500.0
G1 X105.528 Y-25.004 F7500.0
G1 X-63.651 Y-199.106 F7500.0
G1 X12.835 Y-49.614 F7500.0
G1 X39.784 Y180.513 F7500.0
G1 X-86.816 Y117.263 F7500.0
G1 X121.654 Y-136.567 F7500.0
G1 X-139.407 Y-168.443 F7500.0
G1 X137.580 Y73.441 F7500.0
G1 X-116.431 Y195.966 F7500.0
G1 X78.929 Y0.000 F7500.0
G1 X-30.342 Y-195.966 F7500.0
G1 X-22.507 Y-73.441 F7500.0
G1 X72.194 Y168.443 F7500.0
G1 X-111.742 Y136.567 F7500.0
G1 X135.596 Y-117.263 F7500.0
G1 X-140.407 Y-180.513 F7500.0
G1 X125.497 Y49.614 F7500.0
G1 X-92.962 Y199.106 F7500.0
G1 X47.370 Y25.004 F7500.0
G1 X4.874 Y-189.736 F7500.0
G1 X-56.434 Y-96.110 F7500.0
G1 X100.068 Y153.717 F7500.0
G1 X-129.648 Y153.717 F7500.0
G1 X141.019 Y-96.110 F7500.0
G1 X-132.584 Y-189.736 F7500.0
G1 X105.528 Y25.004 F7500.0
G1 X-63.651 Y199.106 F7500.0
G1 X12.835 Y49.614 F7500.0
G1 X39.784 Y-180.513 F7500.0
G1 X-86.816 Y-117.263 F7500.0
G1 X121.654 Y136.567 F7500.0
G1 X-139.407 Y168.443 F7500.0
G1 X137.580 Y-73.441 F7500.0
G1 X-116.431 Y-195.966 F7500.0
G1 X78.929 Y-0.000 F7500.0
M280 P0 S90 T300

I'm a beginner about Arduino :smiley: all help are very welcome ~

What exactly do you want to do with the G-code ?

Send it via the Serial interface perhaps, or something else ?

1 Like

That G code, or G code in general?

consider

const char *gCode [] = {
    "G28",
    "M0",
    "G0 X78.929 Y0.000",
    "M280 P0 S30 T50",
    "G1 X-30.342 Y195.966 F7500.0",
    "G1 X-22.507 Y73.441 F7500.0",
    "G1 X72.194 Y-168.443 F7500.0",
    "G1 X-111.742 Y-136.567 F7500.0",
    "G1 X135.596 Y117.263 F7500.0",
    "G1 X-140.407 Y180.513 F7500.0",
    "G1 X125.497 Y-49.614 F7500.0",
    "G1 X-92.962 Y-199.106 F7500.0",
    "G1 X47.370 Y-25.004 F7500.0",
    "G1 X4.874 Y189.736 F7500.0",
    "G1 X-56.434 Y96.110 F7500.0",
    "G1 X100.068 Y-153.717 F7500.0",
    "G1 X-129.648 Y-153.717 F7500.0",
    "G1 X141.019 Y96.110 F7500.0",
    "G1 X-132.584 Y189.736 F7500.0",
    "G1 X105.528 Y-25.004 F7500.0",
    "G1 X-63.651 Y-199.106 F7500.0",
    "G1 X12.835 Y-49.614 F7500.0",
    "G1 X39.784 Y180.513 F7500.0",
    "G1 X-86.816 Y117.263 F7500.0",
    "G1 X121.654 Y-136.567 F7500.0",
    "G1 X-139.407 Y-168.443 F7500.0",
    "G1 X137.580 Y73.441 F7500.0",
    "G1 X-116.431 Y195.966 F7500.0",
    "G1 X78.929 Y0.000 F7500.0",
    "G1 X-30.342 Y-195.966 F7500.0",
    "G1 X-22.507 Y-73.441 F7500.0",
    "G1 X72.194 Y168.443 F7500.0",
    "G1 X-111.742 Y136.567 F7500.0",
    "G1 X135.596 Y-117.263 F7500.0",
    "G1 X-140.407 Y-180.513 F7500.0",
    "G1 X125.497 Y49.614 F7500.0",
    "G1 X-92.962 Y199.106 F7500.0",
    "G1 X47.370 Y25.004 F7500.0",
    "G1 X4.874 Y-189.736 F7500.0",
    "G1 X-56.434 Y-96.110 F7500.0",
    "G1 X100.068 Y153.717 F7500.0",
    "G1 X-129.648 Y153.717 F7500.0",
    "G1 X141.019 Y-96.110 F7500.0",
    "G1 X-132.584 Y-189.736 F7500.0",
    "G1 X105.528 Y25.004 F7500.0",
    "G1 X-63.651 Y199.106 F7500.0",
    "G1 X12.835 Y49.614 F7500.0",
    "G1 X39.784 Y-180.513 F7500.0",
    "G1 X-86.816 Y-117.263 F7500.0",
    "G1 X121.654 Y136.567 F7500.0",
    "G1 X-139.407 Y168.443 F7500.0",
    "G1 X137.580 Y-73.441 F7500.0",
    "G1 X-116.431 Y-195.966 F7500.0",
    "G1 X78.929 Y-0.000 F7500.0",
    "M280 P0 S90 T300",
};

#define N_Gcode     (sizeof(gCode)/sizeof(char *))

// -----------------------------------------------------------------------------
void
loop (void)
{
}

// -----------------------------------------------------------------------------
void
setup (void)
{
    Serial.begin (9600);

    for (unsigned n = 0; n < N_Gcode; n++)
        Serial.println (gCode [n]);
}

Better to leave it in PROGMEM.

I just want to print the result shape to paper via attached hanging v-plotter :grin:

That G code for now, but this summer I plan to learn G code in general

Oh is it okay if I just paste this to an empty .ino file? Does it work that way?

Or, if you plan to change it a lot in future, place it in a file and read it from an SD card.

No. By itself, it will just sit in memory and do nothing. You need to upload code that uses it.

For now I don't have a SD card module so... but in future maybe I can get an SD module to try in other projects

so, pasting it to an empty .ino file, then send to the device via the arduino app?

I just tried it and, plotter is just waiting lol

What is "it" ?

The solution gcjr wrote through, and I opened a new sketch, pasted it in, and tried :smiley:

How is your plotter connected to the Arduino ?

R3 to Shield5 to 2 motors and, GVS-A0 goes for the penholding part, G11-V11,S10-9-8-7-6-5-4-3-2,G1-V1 to the 2 motors

No wonder the sketch doesn't work as it is trying to use the Serial interface. You need some software to take the G-code and turn it into commands for the motors so that they move as required

Have you got such software ?

Your original post implied that you already had a .ino file that controlled the plotter. Is that right ?

Have you made the plotter do anything at this point?

I don't have a software that turns Gcode to motor commands, but I got this Gcode from Makelangelo.

Yeah I have an ino file for testing the plotter, it works but I want to try the output of this gcode instead of just an infinite loop to display