Im trying to code a communication from PC (Linux) Python Programm to my MicroPython Pico but im unable to find a solution for this. Firt of all: I want to use the standard Micro USB Port on my Pico for this. Is this possible?
PC Code:
#!/usr/bin/python3
import serial
# Serielle Verbindung herstellen
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1) #ACM0 is correct. I checked that with dmesg and minicom
command = "reset"
ser.write(command.encode())
ser.close()
Raspberry Pico Code:
import time
def reset():
print("Reset called")
y_pwm.duty_ns(y_default_value_middle)
time.sleep(0.3)
x_pwm.duty_ns(x_default_value_middle)
while True:
if __name__ == "__main__":
eingabe = input("What do you want to do? (enable_relais, reset): ")
if eingabe == "enable_relais":
enable_relais()
elif eingabe == "reset":
reset()
else:
print("Error.")
time.sleep(0.1)
If i connect to the serial console via minicom i can see the Pico asking for orders and if im calling reset
there it moves its servos to the correct positions but if i try to send reset
with the Python Code above it just does nothing. I need some advice please. How can i just send commands to my pico via my python script?