We open the program and click on "Main Window" and then "Create"
We will create an app to move the servo using a XIAO RP2040. This will be simple, with two buttons: one labeled "Left" and the
other "Right". We'll start by dragging the "Push Button" option, placing two of these and 3 Labels found in "Display Widgets".
In one label, we'll put the title of the app, and in the other two, the names of the buttons.
Now, to change the color of the button, right-click on it and select "Change styleSheet".
In that menu, click on "Add color" and select the text color on the button and "Background-color" for the button's background.
Now, we will change the name of the button so that the interface recognizes it. For the left one, we change it to
"btn_rotate_left" and for the right one to "btn_rotate_right".
Press Ctrl + R to view our app.
Save everything in a folder as a .ui file.
Now we need to install Python (CH) by selecting "Add python.exe to PATH".
Next, open the "Command Prompt" on our computer and navigate using the cd command to enter the folder where we
saved our app design. From there, download PyQt6 with the command pip install PyQt6 pyserial.
We will convert the user interface (UI) to Python using the pyuic6 command. Enter the command
pyuic6 -x servomotor_Interface.ui -o servomotor_Interface.py.
To see how our interface turned out, enter python app.py.
Use the code . command to open the code from Visual Studio. Here we need to create another .py
file with the code shown in the image to separate the interface (Frontend) from the MCU programming (Backend).
In the terminal, we must install pyserial to start communication with the command pip install pyserial and import our code.
We also need to write code in Arduino to upload to the XIAO RP2040.
Finally, run our program with python app.py and test it.