6. Case 03: Dance in Figure-of-eight¶
6.2. Programming Preparation¶
Please refer to: Preparation for the Programming
6.3. Sample code :¶
from cutebot import *
from time import *
# Create a sample for Cutebot category
cutebot = Cutebot()
# Turnning by adjusting the different speed of the left and right wheels of the cutebot.
while True:
cutebot.set_speed(100,50)
sleep(2)
cutebot.set_speed(50,100)
sleep(2)
Code details¶
- Import the modules that we need:
cutebot
module contains classes and functions for Cutebot smart car operations, andtime
module contains functions for time operations.
from cutebot import *
from time import *
- Create a sample for Cutebot category
cutebot = Cutebot()
- Directions turning is done by controlling the speed difference between the left and right wheels of the cutebot smart car.
while True:
cutebot.set_speed(100,50)
sleep(2)
cutebot.set_speed(50,100)
sleep(2)
6.4. Results¶
After turning on the power, the cutebot smart car travels in a figure of 8 trajectory.
6.5. Exploration¶
How should I program the car if I want it to travel in a square trajectory?