• 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: Raspberry Pi 5 Power MP2.5GD Raspberry Pi 5 PCIe to Dual 2.5G Double Ethernet HAT Pi5 RTL8125 SpotPear ESP32 S3 Development Board 1.47 inch LCD Touch Screen 1.47inch Display 172×320 SD AXS5106L JD9853 Desktop RP204 0.85inch LCD Raspberry Pi 64MP Camera Raspberry Pi 7.5 inch e-Paper link (H) RYBW 800x480 For Arduino / Jetson Nano / STM32 Raspberry Pi Camera V2 USB Camera 2MP GC2093 ‌WDR Backlight Compensation‌ Onboard microphone DDSM315 Direct Drive Servo Motor All-In-One Design Hub RS485 Motor Raspberry Pi 15.6 inch QLED Quantum Dot Display 1920x1080 Capacitive Touchscreen For Computer PC/Jetson/Game $167.99 Industrial Grade Isolated USB TO RS232/485 (B) Serial UART Converter FT232RNL For Wall/Rail-Mount here User Guide Industrial USB to RS485 Converter Luckfox Pico Computer USB Monitor Screen X1012 Raspberry Pi 5 POE And PCIe to M.2 NVMe SSD Board Pi5 2280 Power over Ethernet Pi5 Double 2280 Industrial Modbus RTU Dual Ethernet RJ45 To 8ch POE ETH Relay (C) PoE Power over Ethernet