-
-
Save BastelPichi/e8cc4798dcf3f2d5302e2c05da9e655d to your computer and use it in GitHub Desktop.
This file contains 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 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