Skip to content

Instantly share code, notes, and snippets.

@sficarro
Created July 26, 2020 21:22
Show Gist options
  • Save sficarro/679c9f4ee18ad5a174dc45dad9f9eb5c to your computer and use it in GitHub Desktop.
Save sficarro/679c9f4ee18ad5a174dc45dad9f9eb5c to your computer and use it in GitHub Desktop.
A python script that sends g-code to Arduino loaded with GRBL2 arduino
import serial
import time
ser=serial.Serial('COM5', 9600)
counter = 0
ser.write('g0x0\n')
time.sleep(1)
time.sleep(1)
while counter <50:
current = str(int(counter))
print current
a = 'g0x' + current + '\n'
ser.write(a)
print a
time.sleep(2.5)
counter += 2.5
time.sleep(2.5)
while counter >.2:
current = str(int(counter))
print current
a = 'g0x' + current + '\n'
ser.write(a)
print a
time.sleep(2.5)
counter -= 2.5
time.sleep(2.5)
time.sleep(2.5)
ser.write('g0x0\n')
time.sleep(5)
ser.write('g0x0\n')
time.sleep(1)
time.sleep(1)
while counter <50:
current = str(int(counter))
print current
a = 'g0x' + current + '\n'
ser.write(a)
print a
time.sleep(2.5)
counter += 1
time.sleep(2.5)
while counter >.2:
current = str(int(counter))
print current
a = 'g0x' + current + '\n'
ser.write(a)
print a
time.sleep(2.5)
counter -= 1
time.sleep(2.5)
time.sleep(2.5)
ser.write('g0x0\n')
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment