21. Case 19: Sweeper
21.1. Purpose
Build a TPBot sweeper.
21.2. Material
1 x TPBot Smart Car
21.3. Hardware Connection
Connect the 360 degrees servo to servo 1 port on TPBot. (Servos are not included in our TPBot kit)
21.4. Software
21.5. Programming
Click “Advanced” in the MakeCode drawer to see more choices.
We need to add a package for programming. Click “Extensions” in the bottom of the drawer and search with “tpbot” to download it.
Sample
Drag the show icon brick in the on start and set the car to move forward at the speed of 30%; in forever brick, set the servo connecting to S1 rotate to 180 degrees and pause for 1000ms, and set it rotate to 0 degree and pause for 1000ms.
Link
You may also download it directly below:
Conclusion
The car move forward with the servo rotating.
21.6. Exploration
21.7. FAQ
Q: The car cannot move with the code in this case?
A: It might be a lack power of the battery, please add the value of the parameter for the speed of the car and test it.