![]() ![]() Global button_run, button_stop, button_disconnect, req Use DiscoveryService and GATTRequester to find connected devices: def smart_hub_connect(): Label = tk.Label(root, fg="dark green", text='N/A')īutton_connect = tk.Button(root, text='Connect Smart Hub', width=BUTTON_WIDTH, command=connect)īutton_disconnect = tk.Button(root, text='Disconnect Smart Hub', width=BUTTON_WIDTH, command=disconnect, state='disabled')īutton_run = tk.Button(root, text='Run motor', width=BUTTON_WIDTH, command=run, state='disabled')īutton_up = tk.Button(root, text='Speed up', width=BUTTON_WIDTH, command=up, state='disabled')īutton_down = tk.Button(root, text='Speed down', width=BUTTON_WIDTH, command=down, state='disabled')īutton_stop = tk.Button(root, text='Stop motor', width=BUTTON_WIDTH, command=stop, state='disabled') Root.title("Lego Wedo 2.0 Motor Control") To create an interface with Tkinter: import Tkinter as tkīutton_disconnect.after(DELAY, smart_hub_connect)īutton_disconnect.after(DELAY, smart_hub_disconnect) Sudo apt-get install libbluetooth-dev bluez bluez-hcidump libboost-python-dev libboost-thread-dev libglib2.0-dev Install dependency libraries and gattlib: sudo apt-get update Using Python to create interface control program Scan device for address: sudo hcitool -i hci0 lescan I finally chose raspberry pie as the development environment.īluetooth connection can be tested directly by using the command line tool of the system. Through the test, it is found that Linux subsystem and VMWare virtual machine of Windows are not supported. Command line tools and development environment Use pygattlib It can communicate with Bluetooth low power devices through Python. ![]() There are two useful articles on the Internet: This article shares how to use Python to connect and control the Bluetooth master device and motor provided in LEGO Wedo 2.0. Lego's official programming tools are all graphical.
0 Comments
Leave a Reply. |