• 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: Sipeed NanoCluster Mini Cluster Board mini data center For Raspberry Pi CM45 / Computer /LM3H /M4N Mobile Robot NVIDIA Jetson EchoEar ESP32 S3 AI Development Board with 1.85-inch LCD Display Cute Cat Pet Chatting Robot N32R16 Jetson Nano Expansion Board ESP32 C3 Python HTTP Request Communication 1.5inch Display Raspberry Pi 4B/5 Industrial UART 2CH RS485 RS232 CAN FD HAT With Case For Installation of guide rails and hanging ESP32-S3R2 Raspberry Pi RTC WatchDog HAT (B) Real time clock Onboard DS3231SN High Precision RTC Chip Raspberry Pi 5 PCIe TO Gigabit RJ45 ETH Adapter Board (C) Driver-Free RTL8111H For Pi5 ESP32 S3 Development Board 1.91 inch AMOLED Display Screen For Arduino LVGL With SD-Port/ QMI8658C 6-Axis Sensor AV to LVDS Arduino Thermal imaging 1.3inch LCD RP2040-PiZero Game ST7789 Raspberry Pi Pico LCD Display Screen RP2040-PiZero WiFi Wireless ESP32 DDSM Motor Driver HAT For Direct Drive Servo Hub Motors For Raspberry Pi Luckfox Pico Zero RV1106G3 SD WiFi6 Audio eMMC-8G RAM-256MB ESP32 S3 4.3inch LCD (B) 800x480 Captive TouchScreen Display Board LVGL with Sensor CAN I2C RS485