Robotics Program Report - Mbot2
Robotics Program Report - Mbot2
# main.py: Clear
import cyberpi
import event
import time
@event.is_press('a')
def is_btn_press():
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("1", 24, int(0), int(0), index=0)
time.sleep(0.3)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("2", 24, int(55), int(0), index=1)
time.sleep(0.3)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("3", 24, int(110), int(0), index=2)
time.sleep(0.3)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("4", 24, int(0), int(50), index=3)
time.sleep(0.3)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("5", 24, int(55), int(50), index=4)
time.sleep(0.3)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("6", 24, int(110), int(50), index=5)
time.sleep(0.3)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("7", 24, int(0), int(100), index=6)
time.sleep(0.3)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("8", 24, int(55), int(100), index=7)
time.sleep(0.3)
cyberpi.display.clear()
Day 2 - Python Programs
Task 1 - Secret Code Maker:
“Create word1 and word2, combine using +, and print the
secret code.”
# main.py: Clear
word_1 = "dragon"
word_2 = "fly"
print(word_1+word_2)
# main.py: Clear
pot_1=150
pot_2=150
pot_3=150
print("Your Potion has",pot_1+pot_2+pot_3,"ml in total!")
# main.py: Clear
energy_points=45
print("After the crystal, my energy is", energy_points*2,
"Points!")
Task 4 - Treasure Counter:
“Add 15 gold + 23 silver coins. Print total coins.”
# main.py: Clear
gold_coins=15
silv_coins=23
print("Total Coins:", gold_coins+silv_coins, "coins")
# main.py: Clear
magic_level=40
magic_spell=25
print("New Magic Level:", magic_level+magic_spell)
# main.py: Clear
first_name="Arthur"
title=" the brave."
print("Your knight name is:", first_name+title)
current_speed=12
booster_speed=8
new_speed=current_speed+booster_speed
print("New Speed:",new_speed,"km/h")
Task 8 - Dragon Age Doubler:
“Age = 150. Double it. Print new age.”
# main.py: Clear
current_age=150
magic_age=2
new_age=current_age*magic_age
print("The dragon's new age is:", new_age, "years.")
# main.py: Clear
my_books=85
donated_books=17
new_books= my_books-donated_books
print("Books left:", new_books)
# main.py: Clear
for i in range(1,11):
print("T-Minus", i, "seconds!")
i=i+1
print("Launch!")
# main.py: Clear
apples_sold=12
bananas_sold=15
total_sales=apples_sold+bananas_sold
print("Total Fruits Sold:", total_sales)
Task 12 - Lucky Number Creator:
“Multiply 7 × 9. Print lucky number.”
# main.py: Clear
no_1=7
no_2=9
new_no=no_1*no_2
print("Your lucky number is:", new_no)
air_held=2
balloons=7
air_needed=air_held*balloons
print("Total air needed:", air_needed,"litres.")
! Keywords Learnt:
• mbot2.straight({DISTANCE IN CM})
• mbot2.forward({SPEED IN RPM})
• mbot2.backward({SPEED IN RPM})
• mbot2.turn({ANGLE})
• mbot2.EM_turn({DEGREES}, {TIME})
• mbot2.EM_stop({MOTOR})
• mbot2.drive_speed({SPEED OF EM1}, {SPEED OF EM2})
# main.py: Clear
import cyberpi
import mbot2
import event
import time
@event.is_press('a')
def is_btn_press():
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward", 24, 20, 50, index=0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("Turn Left", 24, 10, 50, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward", 24, 20, 50, index=0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("Turn Left", 24, 10, 50, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward", 24, 20, 50, index=0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("Turn Left", 24, 10, 50, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward", 24, 20, 50, index=0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("Turn Left", 24, 10, 50, index=0)
mbot2.turn(92)
cyberpi.display.clear()
@event.is_press('b')
def rectangle_swing_turn():
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward 60", 24, 20, 50, index=0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 100, 0)
cyberpi.display.show_label("Swing Turn", 24, 10, 50, index=0)
mbot2.EM_turn(-90, 1)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward 120", 24, 20, 50, index=0)
mbot2.straight(120)
cyberpi.display.set_brush(255, 100, 0)
cyberpi.display.show_label("Swing Turn", 24, 10, 50, index=0)
cyberpi.display.show_label("Swing Turn", 24, 10, 50, index=0)
mbot2.EM_turn(-90, 1)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward 60", 24, 20, 50, index=0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 100, 0)
cyberpi.display.show_label("Swing Turn", 24, 10, 50, index=0)
mbot2.EM_turn(-90, 1)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Forward 120", 24, 20, 50, index=0)
mbot2.straight(120)
cyberpi.display.set_brush(255, 100, 0)
cyberpi.display.show_label("Swing Turn", 24, 10, 50, index=0)
mbot2.EM_turn(-90, 1)
cyberpi.display.clear()
# main.py: Clear
import cyberpi
import mbot2
import event
import time
# 1st side
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("1st Side", 24, 20, 50, index=0)
mbot2.straight(60)
mbot2.EM_stop()
mbot2.turn(120)
# 2nd side
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("2nd Side", 24, 20, 50, index=0)
mbot2.straight(60)
mbot2.EM_stop()
mbot2.turn(120)
# 3rd side
cyberpi.display.set_brush(0, 0, 255)
cyberpi.display.show_label("3rd Side", 24, 20, 50, index=0)
mbot2.straight(60)
mbot2.EM_stop()
mbot2.turn(120)
$ Issues Faced:
Some times the parenthesis is missed at end end functions and that line
doesnt execute.
Day 3 - The Bakery of Numbers
% Storytime:
In a peaceful village called Digiton, there lived a young baker named Nora.
Nora was famous for baking the finest cakes, cookies, and breads — but not
with regular ingredients. She used numbers to bake!
One day, the Mayor of Digiton announced a math festival. To win the Golden
Spoon, Nora must bake using perfect calculations — involving addition,
subtraction, multiplication, and division. With the help of her clever cat
Minus, Nora must solve a series of challenges in her magical bakery.
# main.py: Clear
current_eggs=10
eggs_added=6
new_eggs1=current_eggs+eggs_added
print("Eggs Nora already has:",current_eggs,"eggs.")
print("Eggs Nora bought now:",eggs_added,"eggs.")
print("Total Eggs Nora has now:",new_eggs1,"eggs.")
# main.py: Clear
current_flour=25
flour_used=7
new_flour=current_flour-flour_used
print("Flour Nora already has:",current_flour,"cups.")
print("Flour Nora has used to bake cookies:",flour_used,"cups.")
print("Remaining flour Nora has now:",new_flour,"cups.")
Task 3 - Bread Orders:
“Each loaf of bread requires 4 cups of flour. How many loaves
can she bake with 36 cups?”
# main.py: Clear
flour_1bread=4
flour_available=36
bread=flour_available/flour_1bread
print("Flour available for baking bread:",flour_available,"cups.")
print("Flour needed for baking 1 bread:",flour_1bread,"cups.")
print("No. of Loaves that can be made:",bread,"loaves.")
# main.py: Clear
pies_sold=5
cost_1pie=8
profit=pies_sold*cost_1pie
print("Pies sold by Nora:",pies_sold,"pies.")
print("Cost of 1 pie:",cost_1pie,"coins.")
print("Money earned by Nora:",profit,"coins.")
# main.py: Clear
cookies_baked=48
box_capacity=6
boxes=cookies_baked/box_capacity
print("Cookies baked by Nora:",cookies_baked,"cookies.")
print("Each box capacity:",box_capacity,"cookies.")
print("Total boxes needed:",boxes,"boxes.")
Task 6 - Total Ingredients:
“Nora uses 2 cups of sugar, 3 cups of flour, and 1 cup of milk
for a new cake. What’s the total ingredient amount?”
# main.py: Clear
sugar=2
flour=3
milk=1
total_ingredients=sugar+flour+milk
print("Cups of sugar used:",sugar)
print("Cups of flour used:",flour)
print("Cups of milk used:",milk)
print("Total ingredients used:",total_ingredients,"cups.")
pies_sold=5
cost_1pie=8
profit=pies_sold*cost_1pie
print("Pies sold by Nora:",pies_sold,"pies.")
print("Cost of 1 pie:",cost_1pie,"coins.")
print("Money earned by Nora:",profit,"coins.")
pies_sold=5
cost_1pie=8
profit=pies_sold*cost_1pie
print("Pies sold by Nora:",pies_sold,"pies.")
print("Cost of 1 pie:",cost_1pie,"coins.")
print("Money earned by Nora:",profit,"coins.")
Task 9 - Equal Division:
“Nora made 60 mini cakes for 4 customers. How many does
each customer get?”
# main.py: Clear
total_mini_cakes=60
customers=4
cakes_each=total_mini_cakes/customers
print("Total mini cakes made:",total_mini_cakes)
print("Total customers:",customers)
print("Each customer gets:",cakes_each,"cakes")
flour_cost=20
sugar_cost=15
eggs_cost=10
total_cost=flour_cost+sugar_cost+eggs_cost
print("Cost of flour:",flour_cost,"coins")
print("Cost of sugar:",sugar_cost,"coins")
print("Cost of eggs:",eggs_cost,"coins")
print("Total cost:",total_cost,"coins")
Day 4 - Intro to LED
! Keywords Learnt:
• cyberpi.led.on({RGB VALUE})
• cyberpi.led.show({COLOUR FOR EACH LED})
• cyberpi.led.play({ANIMATION_NAME})
• cyberpi.led.set_bri({BRIGHTNESS})
• cyberpi.led.add_bri({INCREMENT OF BRIGHTNESS})
• cyberpi.led.get_bri()
import cyberpi
import mbot2
import event
import time
@event.is_press('up')
def led():
cyberpi.display.set_brush(148, 0, 211)
cyberpi.display.show_label("Violet", 24, 40, 50, index=0)
cyberpi.display.show_label("Violet", 24, 40, 50, index=0)
cyberpi.led.on(148, 0, 211)
time.sleep(1)
cyberpi.display.set_brush(75, 0, 130)
cyberpi.display.show_label("Indigo", 24, 40, 50, index=0)
cyberpi.led.on(75, 0, 130)
time.sleep(1)
cyberpi.display.set_brush(0, 0, 255)
cyberpi.display.show_label("Blue", 24, 40, 50, index=0)
cyberpi.led.on(0, 0, 255)
time.sleep(1)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Green", 24, 40, 50, index=0)
cyberpi.led.on(0, 255, 0)
time.sleep(1)
cyberpi.display.set_brush(255, 255, 0)
cyberpi.display.show_label("Yellow", 24, 40, 50, index=0)
cyberpi.led.on(255, 255, 0)
time.sleep(1)
cyberpi.display.set_brush(255, 127, 0)
cyberpi.display.show_label("Orange", 24, 40, 50, index=0)
cyberpi.led.on(255, 127, 0)
time.sleep(1)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.display.show_label("Red", 24, 40, 50, index=0)
cyberpi.led.on(255, 0, 0)
time.sleep(1)
cyberpi.led.off()
cyberpi.display.clear()
$ Issues Faced:
When joystick “up” and joystick “down” are two different events, the code will
not execute if both the functions are defined in the same name, i.e
“def is_btn_press:”
Task 2 - Control LED Brightness and Display
Colors Dynamically:
When the up arrow is pressed, the LED brightness increases
step by step and changes colour based on how bright it is. The
display also shows the brightness value in matching colours.
Once brightness reaches 100, it shows the word “OVER” using
colourful letters.
# main.py: Clear
import cyberpi
import mbot2
import event
import time
@event.is_press('up')
def led():
cyberpi.led.on(255,255,255)
cyberpi.led.set_bri(0)
for i in range(0,11):
time.sleep(1)
cyberpi.led.add_bri(10)
if cyberpi.led.get_bri()>0 and cyberpi.led.get_bri()<21:
cyberpi.led.on(255,0,0)
cyberpi.display.set_brush(255,0,0)
cyberpi.display.show_label(cyberpi.led.get_bri(), 24,
int(50), int(50), index=0)
elif cyberpi.led.get_bri()>21 and cyberpi.led.get_bri()<41:
cyberpi.led.on(0,255,0)
cyberpi.display.set_brush(0,255,0)
cyberpi.display.show_label(cyberpi.led.get_bri(), 24,
int(50), int(50), index=0)
elif cyberpi.led.get_bri()>41 and cyberpi.led.get_bri()<61:
cyberpi.led.on(0,0,255)
cyberpi.display.set_brush(0,0,255)
cyberpi.display.show_label(cyberpi.led.get_bri(), 24,
int(50), int(50), index=0)
elif cyberpi.led.get_bri()>61 and cyberpi.led.get_bri()<81:
cyberpi.led.on(255,0,255)
cyberpi.display.set_brush(255,0,255)
cyberpi.display.show_label(cyberpi.led.get_bri(), 24,
int(50), int(50), index=0)
elif cyberpi.led.get_bri()>81 and cyberpi.led.get_bri()<99:
cyberpi.led.on(255,255,0)
elif cyberpi.led.get_bri()>81 and cyberpi.led.get_bri()<99:
cyberpi.led.on(255,255,0)
cyberpi.display.set_brush(255,255,0)
cyberpi.display.show_label(cyberpi.led.get_bri(), 24,
int(50), int(50), index=0)
elif cyberpi.led.get_bri()==100:
cyberpi.display.clear()
cyberpi.display.set_brush(255,0,0)
cyberpi.display.show_label("O", 24, int(30), int(50),
index=1)
time.sleep(1)
cyberpi.display.set_brush(0,255,0)
cyberpi.display.show_label("V", 24, int(50), int(50),
index=2)
time.sleep(1)
cyberpi.display.set_brush(0,0,255)
cyberpi.display.show_label("E", 24, int(70), int(50),
index=3)
time.sleep(1)
cyberpi.display.set_brush(255,255,0)
cyberpi.display.show_label("R", 24, int(90), int(50),
index=4)
time.sleep(1)
import cyberpi
import mbot2
import event
import time
@event.is_press('a')
def spiral():
mbot2.drive_speed(100,-80,5)
mbot2.drive_speed(100,-60,5)
mbot2.drive_speed(100,-40,5)
mbot2.drive_speed(100,-20,5)
mbot2.drive_speed(100,-5,5)
mbot2.drive_speed(-5,100,5)
mbot2.drive_speed(-20,100,5)
mbot2.drive_speed(-40,100,5)
mbot2.drive_speed(-60,100,5)
mbot2.drive_speed(-80,100,5)
Day 5 - Conditional Statements
Task 1 – Spaceship Direction Check:
“If the assigned_value is greater than or equal to the
direction_code, print that the spaceship entered the wormhole.
Otherwise, print that it got lost in deep space.”
# main.py: Clear
direction_code = 6
assigned_value = 6
if assigned_value < direction_code:
print("The spaceship got lost in deep space!")
else:
print("The spaceship entered the wormhole!")
pass_mark = 40
your_score = 40
if your_score >= pass_mark:
print("You have successfully passed the exam!")
temperature = 30
if temperature == 30:
print("Normal Temperature!")
elif temperature > 30:
print("Warm Temperature!")
else:
print("Cold Temperature!")
Task 4 – Rocket Fuel Check:
“Fuel below 70: Low fuel. Fuel 70 or more: Sufficient. If fuel is
100 or more: Rocket is ready.”
# main.py: Clear
fuel = 75
if fuel >= 100:
print("Rocket is ready to launch!")
elif fuel >= 70:
print("Sufficient fuel to launch the rocket!")
else:
print("Low fuel! Can't launch the rocket!")
radiation_level = 6
if radiation_level <= 2:
print("Safe Zone")
elif radiation_level <= 4:
print("Caution: Moderate Danger")
elif radiation_level >= 8:
print("Caution: Critical")
else:
print("Caution: High Danger")
oxygen = 45
if oxygen <= 20:
print("Critical! Oxygen very low!")
elif oxygen >= 80:
print("Oxygen optimal")
elif oxygen >= 40:
print("Oxygen level Acceptable")
Task 7 – Distance to Planet:
“< 1: Near Planet. > 10: Far Planet. ≥ 4: Medium Range Planet.”
# main.py: Clear
distance = 4.5
if distance < 1:
print("Near Planet")
elif distance > 10:
print("Far Planet")
elif distance >= 4:
print("Medium Range Planet")
battery = 10
if battery <= 10:
print("Battery Critical")
elif battery >= 80:
print("Battery Full")
elif battery >= 50:
print("Battery OK")
england = 270
australia = 270
if england > australia:
print("England won the match")
elif england < australia:
print("England lost the match")
else:
print("Match tied")
Task 10 – Bowler’s Economy Rate:
“≤ 3: Highly economical. ≤ 5: Good control. Else: Too expensive.”
# main.py: Clear
economy_rate = 4.2
if economy_rate <= 3:
print("Highly economical")
elif economy_rate <= 5:
print("Good control")
else:
print("Too expensive")
wickets = 3
if wickets == 5:
print("Match-winning spell!")
elif wickets >= 2:
print("Effective bowler")
else:
print("Needs improvement")
runs = 105
if runs <= 50:
print("Below average performance")
elif runs >= 100:
print("Outstanding! Century scored")
else:
print("Decent knock")
Day 6 - Maze Solving
" Image Preview:
import cyberpi
import mbot2
import event
import time
@event.is_press('a')
def spiral():
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(40)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(27.5)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(24)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(28)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(25)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.straight(25)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(30)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(42)
import cyberpi
import mbot2
import event
import time
@event.is_press('a')
def spiral():
cyberpi.display.set_brush(0, 255, 0)
cyberpi.led.on(0, 255, 0)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(40)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.led.on(0, 255, 0)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(27.5)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.led.on(0, 255, 0)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.led.on(0, 255, 0)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(28.5)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.led.on(0, 255, 0)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(25)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.led.on(0, 255, 0)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(30.5)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.led.on(0, 255, 0)
cyberpi.display.show_label("Go Forward", 16, 24, 56, index=0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 215, 0)
cyberpi.led.on(255, 215, 0)
cyberpi.display.show_label("Victory!", 16, 32, 56, index=0)
Task 3 – Reverse Solving the Maze:
Make the robot start from the finishing point and finish the
maze entirely in reverse.
# main.py: Clear
import cyberpi
import mbot2
import event
import time
@event.is_press('a')
def spiral():
cyberpi.display.set_brush(0, 0, 255)
cyberpi.led.on(0, 0, 255)
cyberpi.display.show_label("Go Backward", 16, 16, 56, index=0)
mbot2.straight(-60)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.set_brush(0, 0, 255)
cyberpi.led.on(0, 0, 255)
cyberpi.display.show_label("Go Backward", 16, 16, 56, index=0)
mbot2.straight(-30.5)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.set_brush(0, 0, 255)
cyberpi.led.on(0, 0, 255)
cyberpi.display.show_label("Go Backward", 16, 16, 56, index=0)
mbot2.straight(-25)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 0, 255)
cyberpi.led.on(0, 0, 255)
cyberpi.display.show_label("Go Backward", 16, 16, 56, index=0)
mbot2.straight(-28.5)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Right", 16, 24, 56, index=0)
mbot2.turn(92)
cyberpi.display.set_brush(0, 0, 255)
cyberpi.led.on(0, 0, 255)
cyberpi.display.show_label("Go Backward", 16, 16, 56, index=0)
mbot2.straight(-24)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.set_brush(0, 0, 255)
cyberpi.led.on(0, 0, 255)
cyberpi.display.show_label("Go Backward", 16, 16, 56, index=0)
mbot2.straight(-27.5)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0)
cyberpi.display.show_label("Turn Left!", 16, 28, 56, index=0)
mbot2.turn(-92)
cyberpi.display.set_brush(0, 0, 255)
cyberpi.led.on(0, 0, 255)
cyberpi.display.show_label("Go Backward", 16, 16, 56, index=0)
mbot2.straight(-40)
Day 7 - Data Type Conversions
in Python
Task 1 - Potion Upgrade:
“Convert the potion strength from string to float, multiply by 2,
and print the upgraded potion strength.”
# main.py: Clear
pot_strength = "3.5"
new_strength = float(pot_strength) * 2
print("The new potion strength is:", new_strength)
coin_1 = "15"
coin_2 = "25"
total = int(coin_1) + int(coin_2)
print("The new total is", total, "coins.")
fuel_load = 80.75
fuel_used = 30.50
fuel_left = int(fuel_load - fuel_used)
print("Fuel Left:", fuel_left, "l.")
Task 4 - Brain Power Boost:
“Convert the string IQ and puzzle bonus to integers, add them,
and print the updated IQ score.”
# main.py: Clear
iq = "120"
iq_puzzle = "10"
new_iq = int(iq) + int(iq_puzzle)
print("Your IQ Level is:", new_iq)
armor_weight = "18.6"
your_weight = "11.4"
tot_weight = int(float(armor_weight) + float(your_weight))
print("Your Total Weight with Armor is:", tot_weight, "kgs.")
speed = "97.5"
boost = "12.5"
total_speed = int(float(speed) + float(boost))
print("The car's speed is:", total_speed, "km/hr.")
speed = "97.5"
boost = "12.5"
total_speed = int(float(speed) + float(boost))
print("The car's speed is:", total_speed, "km/hr.")
Task 7 - Building Blocks:
“Convert current and collected blocks to integers, add them,
and print the total number of building blocks.”
# main.py: Clear
blocks = "300"
collected = "125"
total_blocks = int(int(blocks) + int(collected))
print("Total number of blocks:", total_blocks)
accuracy = "82.5"
rounded_accuracy = round(float(accuracy))
print("Rounded accuracy is:", rounded_accuracy)
charge = "65.25"
charge_float = float(charge)
new_charge = float(charge_float + (0.105 * charge_float))
print("Battery charge after boost is:", new_charge, "%")
speed = "97.5"
boost = "12.5"
total_speed = int(float(speed) + float(boost))
print("The car's speed is:", total_speed, "km/hr.")
Task 11 - Magic Power Multiplier:
“Convert power from string to float, multiply it by 2.5, and
print your new magic power level.”
# main.py: Clear
blocks = "300"
collected = "125"
total_blocks = int(int(blocks) + int(collected))
print("Total number of blocks:", total_blocks)
slots = "25"
extra_slots = "15"
total_slots = int(int(slots) + int(extra_slots))
print("Total backpack slots:", total_slots)
apple_juice = "1.5"
orange_juice = "2.0"
total_juice = float(float(apple_juice) + float(orange_juice))
print("Total juice mixed is:", total_juice, "liters")
temperature = "102.7"
cooling = "7.2"
new_temperature = float(float(temperature) - float(cooling))
print("New engine temperature is:", new_temperature, "°C")
Day 8 - Audio & Recording
! Keywords Learnt:
• cyberpi.audio.record()
• cyberpi.audio.stop_record()
• cyberpi.audio.play_record_until()
• cyberpi.audio.play_record()
• cyberpi.audio.play_music({NOTE_VALUE}, {DURATION})
• cyberpi.audio.add_tempo({TEMPO_INCREMENT})
• cyberpi.audio.set_tempo({NEW_TEMPO})
• cyberpi.audio.stop()
• cyberpi.audio.play_tone({FREQUENCY}, {DURATION})
• cyberpi.audio.add_vol({VOLUME_INCREMENT})
• cyberpi.audio.set_vol({VOLUME_LEVEL})
• cyberpi.audio.get_vol()
• cyberpi.audio.get_tempo()
• cyberpi.display.show_label(cyberpi.audio.get_vol(),
{FONT_SIZE}, {X_POSITION}, {Y_POSITION}, index =
{LABEL_INDEX})
• cyberpi.display.show_label(cyberpi.audio.get_tempo(),
{FONT_SIZE}, {X_POSITION}, {Y_POSITION}, index =
{LABEL_INDEX})
@event.start
def on_start():
for i in range(1, 6):
say_number(i)
def say_number(n):
if n == 1:
if n == 1:
say_text, said_text, say_chars, said_chars = "Say: 1", "You
said: 1", 6, 11
elif n == 2:
say_text, said_text, say_chars, said_chars = "Say: 2", "You
said: 2", 6, 11
elif n == 3:
say_text, said_text, say_chars, said_chars = "Say: 3", "You
said: 3", 6, 11
elif n == 4:
say_text, said_text, say_chars, said_chars = "Say: 4", "You
said: 4", 6, 11
else:
say_text, said_text, say_chars, said_chars = "Say: 5", "You
said: 5", 6, 11
cyberpi.display.clear()
cyberpi.display.show_label(say_text, 24, x1, y, index=0)
cyberpi.led.on(0, 255, 0)
time.sleep(0.5)
cyberpi.audio.record()
time.sleep(5)
cyberpi.audio.stop_record()
time.sleep(1)
cyberpi.led.on(255, 0, 0)
cyberpi.display.clear()
cyberpi.display.show_label(said_text, 24, x2, y, index=0)
cyberpi.audio.set_vol(100)
time.sleep(1)
cyberpi.led.on(0, 0, 255)
cyberpi.audio.play_record_until()
cyberpi.led.off()
time.sleep(1)
Day 9 - Ultrasonic Sensor
! Keywords Learnt:
• import mbuild
• mbuild.ultrasonic2.get()
• mbuild.ultrasonic2.set_bri({BRIGHTNESS}, "all")
• mbuild.ultrasonic2.add_bri({BRIGHTNESS}, "all”)
• mbuild.ultrasonic2.get_bri()
• mbuild.ultrasonic2.play(“{EMOTION}”)
@event.start
def on_start():
while True:
if mbuild.ultrasonic2.get(1) <= 20:
mbot2.forward()
cyberpi.led.on(0,255,0)
cyberpi.display.set_brush(0,255,0)
cyberpi.display.show_label("Go", 24, "center", index=0)
else:
mbot2.EM_stop("all")
cyberpi.audio.set_vol(100)
cyberpi.audio.play_tone(int(1000), 0.7)
cyberpi.led.on(255,0,0)
cyberpi.display.set_brush(255,0,0)
cyberpi.display.show_label("Stop", 24, "center", index=0)
Task 2 - Ultrasonic Range Sensor:
“The robot continuously checks the distance using an
ultrasonic sensor. If an object is less than 20 cm away, it stops,
plays a 1000 Hz warning tone, displays “Too Close!” in red, and
the LED turns red, simulating an ambulance alert. If the path
is clear, the robot moves forward and shows “Moving…”. Based
on the distance range, the LED changes colour and displays
messages like “Range 20-30”, “Range 50-60”, etc., giving real-
time feedback with both text and colour.”
# main.py: Clear
@event.start
def on_start():
while True:
distance = mbuild.ultrasonic2.get(1)
cyberpi.display.clear()
else:
mbot2.forward()
cyberpi.display.set_brush(255, 255, 255)
cyberpi.display.show_label("Moving...", 18, "top",
index=0)
else:
cyberpi.led.on(0, 255, 0)
cyberpi.display.set_brush(0, 255, 0)
cyberpi.display.show_label("Moving...", 24,
"center", index=1)
Day 9 - Ultrasonic Sensor Maze
" Image Preview:
@event.is_press('a')
def is_btn_press():
while True:
cyberpi.display.show_label(str(str('U.S.= ') +
str(mbuild.ultrasonic2.get(1))) + str('cm'), 16, "bottom_mid",
index= 1)
@event.is_press('a')
def is_btn_press1():
time.sleep(4)
Go_Forward()
Turn_Left()
Go_Forward()
Turn_Left()
Go_Forward()
Turn_Right()
Go_Forward()
Turn_Right()
Go_Forward()
Turn_Left()
Go_Forward()
Turn_Left()
Stop()
def Turn_Right():
mbot2.turn(90)
cyberpi.display.set_brush(0, 186, 255)
cyberpi.led.on(0, 186, 255, "all")
cyberpi.display.show_label("Turn Right!", 16, "center", index=
0)
def Turn_Left():
mbot2.turn(-90)
cyberpi.display.set_brush(255, 226, 0)
cyberpi.led.on(255, 227, 0, "all")
cyberpi.display.show_label("Turn Left!", 16, "center", index=
0)
def Go_Forward():
while mbuild.ultrasonic2.get(1) > 7:
mbot2.forward(20)
cyberpi.display.set_brush(0, 255, 8)
cyberpi.led.on(0, 255, 21, "all")
cyberpi.display.show_label("Go Forward!", 16, "center",
index= 0)
mbot2.EM_stop("ALL")
time.sleep(1)
def Stop():
cyberpi.display.set_brush(63, 255, 0)
cyberpi.led.on(42, 255, 0, "all")
cyberpi.display.show_label("Go Forward!", 16, "center", index=
0)
mbot2.straight(60)
cyberpi.display.set_brush(255, 0, 0)
cyberpi.led.on(255, 0, 0, "all")
cyberpi.display.show_label("Stop!", 16, "center", index= 0)
Day 10 - Ultrasonic Sensor
contd.
Task 1 - Knock the Pins:
“The robot spins continuously to search for pins using its
ultrasonic sensor. When it detects a pin within 45 cm, it moves
forward to knock it down, plays a buzzing sound, updates the
number of knocked pins on the display, and returns to its
original position. The display shows the current movement
status, the number of pins knocked, and the ultrasonic sensor
reading in real-time. The process starts when button ‘A’ is
pressed.”
# main.py: Clear
import mbot2,mbuild,event,time,cyberpi
Pins_Pushed=0
Direction=0
def Sense():
global Pins_Pushed
mbot2.drive_speed(20,20)
time.sleep(0.2)
while not mbuild.ultrasonic2.get(1)<45:pass
mbot2.EM_stop("ALL")
time.sleep(2)
cyberpi.audio.play_until('buzzing')
mbot2.forward(120,1.4)
Pins_Pushed+=1
time.sleep(0.2)
mbot2.turn(-360)
time.sleep(0.2)
mbot2.backward(120,1.4)
mbot2.EM_stop("ALL")
time.sleep(1)
@event.start
def on_start():
global Pins_Pushed,Direction
Pins_Pushed=0
Direction="Not Moving!"
cyberpi.audio.set_vol(100)
while True:
cyberpi.audio.set_vol(100)
while True:
cyberpi.display.show_label(Direction,12,"top_mid",index=0)
cyberpi.display.show_label('Pushed '+str(Pins_Pushed)+'
Pins',24,"center",index=1)
cyberpi.display.show_label('U.S.=
'+str(mbuild.ultrasonic2.get(1))+'cm',16,"bottom_mid",index=2)
@event.is_press('a')
def is_btn_press():
global Pins_Pushed,Direction
while True:Sense()
Day 10 - Quad. RGB Sensor
Task 1 - Display:
“The robot checks the color detected by the Quad RGB sensor
on port R1. If the color is black, it lights up LEDs in different
colors and displays the word “black” letter by letter on the
screen. For any other color, it clears the display, sets the LED
and screen brush to the detected color, and shows the color
name at the center.”
# main.py: Clear
@event.start
def on_start():
while True:
if mbuild.quad_rgb_sensor.get_color_sta("R1",1) == 'black':
cyberpi.led.on(165, 0, 255, 1)
cyberpi.display.set_brush(225, 0, 255)
cyberpi.display.show_label("b", 24, int(30), int(52), index = 1)
time.sleep(0.5)
cyberpi.led.on(40, 2, 255, 2)
cyberpi.display.set_brush(38, 0, 255)
cyberpi.display.show_label("l", 24, int(35), int(52), index = 2)
time.sleep(0.5)
cyberpi.led.on(0, 144, 255, 3)
cyberpi.display.set_brush(0, 255, 255)
cyberpi.display.show_label("a", 24, int(50), int(52), index = 3)
time.sleep(0.5)
cyberpi.led.on(0, 255, 46, 4)
cyberpi.display.set_brush(0, 255, 42)
cyberpi.display.show_label("c", 24, int(65), int(52), index = 4)
time.sleep(0.5)
cyberpi.led.on(255, 208, 0, 5)
cyberpi.display.set_brush(212, 255, 0)
cyberpi.display.show_label("k", 24, int(80), int(52), index = 5)
time.sleep(0.5)
else:
cyberpi.console.clear()
cyberpi.led.on(mbuild.quad_rgb_sensor.get_color_sta("R1",1),
"all")
cyberpi.display.set_brush(mbuild.quad_rgb_sensor.get_color_sta("R1",1))
cyberpi.display.set_brush(mbuild.quad_rgb_sensor.get_color_sta("R1"
,1))
cyberpi.display.show_label(mbuild.quad_rgb_sensor.get_color_sta("R2
",1), 24, "center", index= 0)
@event.start
def on_start():
global Direction, Lines
Direction = "Not Moving!"
while True:
cyberpi.display.show_label(Direction, 16, "top_mid", index= 0)
cyberpi.display.show_label(str('Sensed') + str(str(Lines) +
str('Lines.')), 24, "center", index= 1)
@event.is_press('a')
def is_btn_press():
global Direction, Lines
for count in range(4):
Go_Forward()
def Go_Forward():
global Direction, Lines
cyberpi.audio.set_vol(100)
Task 3 - Kinds of Line Stoppers:
“The robot uses the joystick and button inputs to follow lines
based on sensor readings. When the joystick ‘up’ is pressed, it
performs a smooth line following action until it detects red.
Pressing ‘a’ triggers a right-sided line follower that continues
until it sees yellow, while ‘b’ activates a left-sided line follower
that runs until it detects blue. In each case, the robot adjusts
its wheel speeds based on black and white line detection
using its left and right sensors, and stops upon reaching the
specified color.”
# main.py: Clear
@event.is_press('b')
def is_left():
while not (mbuild.quad_rgb_sensor.is_color("blue","R2",1)):
if (mbuild.quad_rgb_sensor.is_color("white","R2",1)) and
(mbuild.quad_rgb_sensor.is_color("black","L2",1)):
mbot2.drive_speed(30, 0)
else:
mbot2.drive_speed(0, -30)
mbot2.EM_stop("all")
@event.is_press('a')
def is_right():
while not (mbuild.quad_rgb_sensor.is_color("yellow","R2",1)):
if (mbuild.quad_rgb_sensor.is_color("white","R2",1)) and
(mbuild.quad_rgb_sensor.is_color("black","L2",1)):
mbot2.drive_speed(0, -30)
else:
mbot2.drive_speed(30, -0)
mbot2.EM_stop("all")
Day 11 - MakeX Challenges
Task 1 - Launch the Cube:
“The robot moves from the start point to the launcher and hits
the launcher inorder to launch the cube without pushing over
the launcher.”
# main.py: Clear
@event.start
def on_start():
while True:
cyberpi.display.show_label(round(-cyberpi.get_yaw(), 1), 24,
"center", index=0)
@event.is_press('b')
def is_btn_press():
cyberpi.reset_rotation('all')
cyberpi.reset_yaw()
cyberpi.led.on(0,0,255) # Indicate reset
@event.is_press('a')
def is_btn_press1():
moving_straight = False # Track straight state
while True:
yaw = -cyberpi.get_yaw()
moving_straight = False
time.sleep(0.05)
@event.start
def on_start():
while True:
cyberpi.display.show_label(round(-cyberpi.get_yaw(), 1), 24,
"center", index=0)
@event.is_press('b')
def is_btn_press():
cyberpi.reset_rotation('all')
cyberpi.reset_yaw()
cyberpi.led.on(0, 0, 255) # Blue for reset
@event.is_press('a')
def is_btn_press1():
# Get current yaw angle
yaw = -cyberpi.get_yaw()
# Aligned — status
cyberpi.display.show_label("Aligned!", 16, "bottom_mid", index=1)
cyberpi.display.show_label("Aligned!", 16, "bottom_mid",
index=1)
cyberpi.led.on(0, 255, 0)
cyberpi.audio.play_until('ring')
# ➤ Continue path
mbot2.straight(25, 50)
time.sleep(0.5)
mbot2.turn(90)
time.sleep(0.5)
mbot2.straight(10, 50)
time.sleep(0.5)
mbot2.turn(180)
time.sleep(0.5)
mbot2.straight(10, 50)
time.sleep(0.5)
mbot2.turn(-90)
time.sleep(0.5)
mbot2.straight(25, 50)
time.sleep(0.5)
cyberpi.led.on(255, 255, 0)
cyberpi.display.show_label("Done!", 16, "bottom_mid", index=1)
cyberpi.audio.play_until('ring')
Day 12 - Gyro + Quad RGB Sensor
Task 1 - Color Cards Parking:
“The robot senses the color shown to it and parks it self in the
same color shown to the robot and goes to next colour shown
directly from that place.”
# main.py: Clear
@event.start
def on_start():
cyberpi.display.show_label("Start Program!", 24, "center", index=0)
while True:
cyberpi.display.show_label(-cyberpi.get_yaw(), 16, "top_mid",
index=1)
cyberpi.display.show_label(mbuild.quad_rgb_sensor.get_color_sta("R2", 1),
16, "bottom_mid", index=2)
@event.is_press('a')
def is_btn_press():
cyberpi.reset_yaw()
cyberpi.reset_rotation('all')
@event.is_press('b')
def is_btn_press1():
cyberpi.display.show_label("Sensing Color!", 24, "center", index=0)
while True:
if mbuild.quad_rgb_sensor.is_color("yellow", "R2", 1):
cyberpi.display.show_label("Sensed Yellow!", 24, "center",
index=0)
while not (-cyberpi.get_yaw() > 43 and -cyberpi.get_yaw() <
47):
mbot2.drive_speed(15, 15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(50)
cyberpi.display.show_label("Reached Yellow!", 24, "center",
index=0)
while not not (mbuild.quad_rgb_sensor.is_color("black", "R2",
1)):
pass
if mbuild.quad_rgb_sensor.is_color("yellow", "R2", 1):
cyberpi.display.show_label("Already at Yellow!", 24,
"center", index=0)
else:
if mbuild.quad_rgb_sensor.is_color("blue", "R2",
1):
cyberpi.display.show_label("Sensed Blue!", 24,
"center", index=0)
while not (-cyberpi.get_yaw() > 178 and
-cyberpi.get_yaw() < 180):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached Blue!", 24,
"center", index=0)
else:
if mbuild.quad_rgb_sensor.is_color("green",
"R2", 1):
cyberpi.display.show_label("Sensed Green!",
24, "center", index=0)
while not (-cyberpi.get_yaw() > -137 and
-cyberpi.get_yaw() < -133):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached
Green!", 24, "center", index=0)
else:
if mbuild.quad_rgb_sensor.is_color("red",
"R2", 1):
cyberpi.display.show_label("Sensed
Red!", 24, "center", index=0)
while not (-cyberpi.get_yaw() > -88 and
-cyberpi.get_yaw() < -92):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached
Red!", 24, "center", index=0)
time.sleep(1)
else:
if mbuild.quad_rgb_sensor.is_color("blue", "R2", 1):
cyberpi.display.show_label("Sensed Blue!", 24,
"center", index=0)
while not (-cyberpi.get_yaw() > 133 and
-cyberpi.get_yaw() < 137):
mbot2.drive_speed(15, 15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(50)
cyberpi.display.show_label("Reached Blue!", 24,
"center", index=0)
while not not (mbuild.quad_rgb_sensor.is_color("black", "R2",
1)):
pass
if mbuild.quad_rgb_sensor.is_color("yellow", "R2",
1):
cyberpi.display.show_label("Sensed Yellow!",
24, "center", index=0)
while not (-cyberpi.get_yaw() > -2 and
-cyberpi.get_yaw() < 2):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached Yellow!",
24, "center", index=0)
else:
if mbuild.quad_rgb_sensor.is_color("blue",
"R2", 1):
cyberpi.display.show_label("Already at
Blue!", 24, "center", index=0)
else:
if mbuild.quad_rgb_sensor.is_color("green",
"R2", 1):
cyberpi.display.show_label("Sensed
Green!", 24, "center", index=0)
while not (-cyberpi.get_yaw() > -92 and
-cyberpi.get_yaw() < -88):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached
Green!", 24, "center", index=0)
else:
if
mbuild.quad_rgb_sensor.is_color("red", "R2", 1):
cyberpi.display.show_label("Sensed
Red!", 24, "center", index=0)
while not (-cyberpi.get_yaw() > -47
and -cyberpi.get_yaw() < -43):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached
Red!", 24, "center", index=0)
time.sleep(1)
else:
if mbuild.quad_rgb_sensor.is_color("green", "R2",
1):
cyberpi.display.show_label("Sensed Green!", 24,
"center", index=0)
while not (-cyberpi.get_yaw() > -137 and
-cyberpi.get_yaw() < -135):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(50)
cyberpi.display.show_label("Reached Green!",
24, "center", index=0)
while not not
(mbuild.quad_rgb_sensor.is_color("black", "R2", 1)):
pass
if mbuild.quad_rgb_sensor.is_color("yellow",
"R2", 1):
while not (-cyberpi.get_yaw() > 43 and
-cyberpi.get_yaw() < 47):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached
Yellow!", 24, "center", index=0)
else:
if mbuild.quad_rgb_sensor.is_color("blue",
"R2", 1):
cyberpi.display.show_label("Sensed
Blue!", 24, "center", index=0)
while not (-cyberpi.get_yaw() > 88 and
-cyberpi.get_yaw() < 92):
mbot2.drive_speed(-15, -15)
mbot2.EM_stop("ALL")
time.sleep(1)
mbot2.straight(70)
cyberpi.display.show_label("Reached
Blue!", 24, "center", index=0)
else:
if
mbuild.quad_rgb_sensor.is_color("green", "R2", 1):
cyberpi.display.show_label("Already
at Green!", 24, "center", index=0)
else:
if
mbuild.quad_rgb_sensor.is_color("red", "R2", 1):
time.sleep(1)