Replies: 1 comment 1 reply
-
Here is an example of doing exactly that: https://pybricks.com/projects/tutorials/wireless/hub-to-device/pc-communication/ |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I’m working on a project where I want to rotate a motor on the Inventor Hub if a value I retrieve from the internet is greater than 5. My idea is to connect to the Inventor Hub via Bluetooth using PyCharm, and if the incoming data is greater than 5, the motor should rotate. Of course, the hub is connected via Pybricks, and when it receives the “move” command, the motor will rotate. However, I haven’t been able to establish the connection yet. I would really appreciate your help on how to achieve this.
from pybricks.hubs import InventorHub
from pybricks.pupdevices import Motor
from pybricks.parameters import Port, Axis
from pybricks.tools import wait
Initialize the hub and motor
inventor_hub = InventorHub(top_side=Axis.Z, front_side=Axis.X)
motor = Motor(Port.A)
print("Waiting for command via Bluetooth...")
while True:
# Waiting for a command via Bluetooth
command = input("Command: ")
if command == "MOVE":
# Rotate motor 360 degrees at 500 deg/sec
motor.run_angle(500, 360)
inventor_hub.speaker.beep()
print("Motor moved.")
elif command == "STOP":
# Stop the program
print("Stopped.")
break
Beta Was this translation helpful? Give feedback.
All reactions