Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Every print job is just a long text file of G-code commands. Understanding the basic commands — and being able to read/write them manually — lets you diagnose what the slicer told the printer to do, write custom start/end sequences, and use the printer as a controllable machine for tasks like dispensing or pen-plotting.
The G-code commands you'll see every print.
Use these three in order. Each builds on the one before.
In one paragraph, explain what G-code is and why every printer uses it.
Walk me through what each command in a typical print's first 20 lines does.
Design a custom start G-code that warms up, homes, levels, and 'nozzle wipes' the bed before printing.
; A typical print starts with setup commands:
G90 ; absolute positioning
M83 ; relative extruder mode (sliced files usually use this)
M104 S210 ; set hotend temp to 210C (no wait)
M140 S60 ; set bed temp to 60C (no wait)
M109 S210 ; wait for hotend to reach 210C
M190 S60 ; wait for bed to reach 60C
G28 ; home all axes
G29 ; auto-bed-level (build mesh)
; Then comes the print itself, generated by the slicer:
G1 X10 Y10 Z0.2 F3000 ; move to start of layer 1, no extrusion
G1 X100 Y10 E5.0 F600 ; extrude 5mm of filament while moving in X
G1 Z0.4 F600 ; move up to layer 2
...
; Thousands of these for a typical print.
; End of print:
M104 S0 ; turn off hotend
M140 S0 ; turn off bed
G91 ; relative positioning
G1 Z10 ; raise nozzle 10mm
G90 ; absolute positioning
G28 X Y ; home X and Y (presents print)
M84 ; disable motors
; Common commands you'll write yourself:
M117 "Hello!" ; display message on LCD
M601 ; pause print
M600 ; filament change (color swap)
M84 ; disable motors (useful for filament inspection)
G92 E0 ; reset the extruder position counter
M220 S100 ; flow rate at 100% (adjust mid-print to fix under/over extrusion)
M221 S100 ; feed rate at 100% (adjust mid-print to speed up/slow down)
In Klipper, many of these are replaced with macros like:
M104 -> SET_HEATER_TEMPERATURE HEATER=extruder TARGET=210
G29 -> BED_MESH_CALIBRATE
But Klipper still parses standard G-code for compatibility.