User Manual
Table Of Contents
- 1. Premise
- 2. Raspberry Pi System Installation and Developmen
- 3 Log In to The Raspberry Pi and Install The App
- 4 Raspberry Pi Structure Assembly and Precautions
- 5 Controlling A Robot via WEB App
- 6 Common Problems and Solutions(Q&A)
- 7 Set The Program to Start Automatically
- 8 Remote Operation of Raspberry Pi Via MobaXterm
- 9 How to Control WS2812 RGB LED
- 10 How to Control The Servo
- 11 Calling the API to Control the Robot
- 12 Automatic Stabilization Function
- 13 Gait Generation Method of A Hexapod Robot
- 14 Make A Police Light or Breathing Light
- 15 Real-Time Video Transmission
- 16 Why OpenCV Uses Multi-threading to Process Vide
- 17 OpenCV Learn to Use OpenCV
- 18 Using OpenCV to Realize Color Recognition and T
- 19 Machine Line Tracking Based on OpenCV
- 20 Create A WiFi Hotspot on The Raspberry Pi
- 21 Install GUI Dependent Item under Window
- 22 How to Use GUI
- 23 Enable UART
- 24 Control Your Adeept_RaspClaws with An Android D
- Conclusion
69
10.3 Non-blocking Control
●You can find the RPIservo.py file in the server folder of the robot product, copy it to the same folder as
the program you want to run, and then you can use this method in your program.
import RPIservo # Import a library that uses multiple threads to control the steering gear
import time
sc = RPIservo.ServoCtrl() # Instantiate the object that controls the steering gear
sc.start() # Start this thread, when the servo does not move, the thread is suspended
while 1:
sc.singleServo(3, -1, 2)
time.sleep(1)
sc.stopWiggle()
sc.singleServo(3, 1, 2)
time.sleep(1)
sc.stopWiggle()
●The above code can be used to control the servo to reciprocate, except for time.sleep (), it will not block
the running of the context program.
●Call singleServo () to start the movement of the servo, call stopWiggle () to stop the movement of the
servo, where singleServo ()Three parameters are required, which are the port number of the servo to be
controlled (3 is to control the No. 3 servo connected to Motor HAT), the movement direction of the servo (1 or
-1), and the movement speed of the servo (the greater the value, the greater The sooner).