Skip to content

Instantly share code, notes, and snippets.

@BastelPichi
Created August 18, 2022 09:08
Show Gist options
  • Save BastelPichi/e8cc4798dcf3f2d5302e2c05da9e655d to your computer and use it in GitHub Desktop.
Save BastelPichi/e8cc4798dcf3f2d5302e2c05da9e655d to your computer and use it in GitHub Desktop.
import time
import serial
from pyautogui import press
serial = serial.Serial(input("Port? "))
pos = 0
print("Go in")
for i in range(5, 0, -1):
time.sleep(1)
print(i)
def map_range(value, inMin, inMax, outMin, outMax):
return outMin + (((value - inMin) / (inMax - inMin)) * (outMax - outMin))
serial.readline()
while True:
read = serial.readline()
val = int(read.decode().rstrip("\r").rstrip("\n")) // 10
print(read, val, pos)
if val > pos:
press("up")
pos += 1
if val < pos:
press("down")
pos -= 1
time.sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment