Skip to content

Instantly share code, notes, and snippets.

@FoamyGuy
Created December 30, 2021 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FoamyGuy/a5a743886c9c07fa2beab3a21fcd3fdb to your computer and use it in GitHub Desktop.
Save FoamyGuy/a5a743886c9c07fa2beab3a21fcd3fdb to your computer and use it in GitHub Desktop.
import serial
import time
send_time = 4 # sec after starting
sent = False
START_TIME = time.monotonic()
with serial.Serial('/dev/ttyACM0', 19200, timeout=1) as ser:
while True:
if not sent:
if time.monotonic() - START_TIME >= send_time:
print("sending")
ser.write(b'q\r\n')
sent = True
line = ser.readline() # read a '\n' terminated line
if line:
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment