Created
December 30, 2021 21:08
-
-
Save FoamyGuy/a5a743886c9c07fa2beab3a21fcd3fdb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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