• sales

    +86-0755-88291180

Chapter 7 of KitiBot-Microbit: Shaking, KitiBot User Guide

Shaking, KitiBot

In this chapter we learn how to control the steering gear as well as how to make the robot shake its 'head'.

Servo


The steering gear is a servo control. The head of the robot is fitted with a steering gear and he can rotate a certain angle. Below is the block to control the steering gear


: This block could be used to control servo

At 90 degrees, the robot looks forward;

At 0 degrees, the robot looks to the right;

At 180 degrees, the robot looks to the left.


After downloading, the robot shakes its head quickly looking forward. If robot didn't look forward, you can adjust the head of robot to look forward.

Control servo with button



Press A, robot shake to left, and it shake right if press B. Keep forward when both A and B are pressed.

Control shaking angle


Let robot shakes slower and stop in certain angle.


We divided the range of 0 to 180 degrees into several parts within an average. Pressing the key to turn the head, it will move to its next division. If the button is still pressed it will move to the next division and so on, until it reaches a top.


Here, we first set both “pos” and “step” variables. Pos value represents the current position of the steering gear. Step represents the angle of each rotation. A positive number means a left turn. And a negative number means a right turn.


The program starts by setting the “pos” to 90 degrees and turning the steering wheel to 90 degrees.That is, making the robot facing forward.

Then, the program enters into an infinite loop, and determines whether A/B buttons are pressed or released. If the key A is pressed, the step is set to 5, which means the robot looks to the left and turns 5 degrees each time. If the key B is pressed, the step is set to -5, which means the robot looks to the right, turning 5 degrees each time.

Increases the current angle “pos” by its current “step” value, this is the next angle robot will shake.

【Note】If the step is a positive integer, the value of the POS increases, and if the step is a negative integer, the value of the POS decreases. The allowed angle range of servo is from 0 to 180.


Finally, don't forget to let the servo shake to new degree, robot could only shake with this block.Change the pause time could change the shaking speed


TAG: UGV Rover PT Kit AI OpenCV Robot Car MediaPipe For Jetson Orin Luckfox Pico MINI 1.54inch LCD TouchScreen Display 240×240 ST7789S For Arduino /Raspberry Pi /ESP32 /Pico /STM32 ESP32-P4-WIFI6 5inch LCD Display AI Development Board 720×1280 5 inch TouchScreen Deepseek Industrial Modbus POE ETH RJ45 To Relay 30CH RTU/Modbus TCP-Ethernet For IOT Raspberry Pi USB Camera 5MP OS05A10 Distortion-Free USB 2.0 For Jeston RDK DeepSeek XiaoZhi AI Chat Robot ESP32-S3 1.54 inch LCD N16R8 MUMA Development Board Display Screen Wifi Weather Station TimeClock ESP32-C3 1.47 inch LCD Display Development Board 1.47inch Screen SD 172×320 EyeLink-RC-S1 Industrial Edition 5.5 inch Touchscreen Camera R1M Card Recording Flight Controller FPV Drone ground station image transmission remote Raspberry Pi Camera Module 3 Sensor Assembly IMX708 Official Original 11.9MP Camera Milk V UART Serial TTL To RS232 B Built-In Protection Circuits Rail-mount Onboard ESP32-C6 Development Board Raspberry Pi 4 USB Audio Supports Night Vision Intel 12th Raspberry Pi DS3231 MK20 Computer AI Deepseek Mechanical Voice Keyboard Linux 20x0.85inch LCD Screen Customize keys + 2.8 inch Secondary Display Xiaozhi AI video tutorial Jetson RTL8822CE 5GHz WiFi Wireless Bluetooth5 Card NGFF-M.2 RTL8822CE-CG Core