""" https://www.elecfreaks.com/learn-en/microbitKit/smart_cutebot/cutebot_case03.html """ from microbit import * import cutebot display.show(Image.PACMAN) while True: cutebot.go_forward() sleep(200) cutebot.set_motors_speed(100, 40) sleep(1000) cutebot.go_forward() sleep(200) cutebot.go_forward() sleep(200) cutebot.set_motors_speed(40, 100) sleep(1000) cutebot.go_forward() sleep(200)
""" https://www.elecfreaks.com/learn-en/microbitKit/smart_cutebot/cutebot_case05.html """ from micropython import const from microbit import * import cutebot # change this value to set different speed SPEED = cutebot.FULL_SPEED # change this value to set minimal light level to turn of the lights MIN_LIGHT = const(10) cutebot.set_motors_speed(SPEED, SPEED) while True: light = display.read_light_level() if light < MIN_LIGHT: cutebot.set_left_rgb_led(cutebot.RGB_MAX, cutebot.RGB_MAX, cutebot.RGB_MAX) cutebot.set_right_rgb_led(cutebot.RGB_MAX, cutebot.RGB_MAX, cutebot.RGB_MAX) else: cutebot.set_left_rgb_led(cutebot.RGB_MIN, cutebot.RGB_MIN, cutebot.RGB_MIN) cutebot.set_right_rgb_led(cutebot.RGB_MIN, cutebot.RGB_MIN, cutebot.RGB_MIN)
""" https://www.elecfreaks.com/learn-en/microbitKit/smart_cutebot/cutebot_case04.html """ import random from microbit import * import cutebot # Uncomment this to set different pseudo-random generator seed. # random.seed(666) display.show(Image.GHOST) while True: left_speed = random.randint(-100, 100) right_speed = random.randint(-100, 100) cutebot.set_motors_speed(left_speed, right_speed) sleep(1000)
""" https://www.elecfreaks.com/learn-en/microbitKit/smart_cutebot/cutebot_case02.html """ from microbit import * import cutebot display.show(Image.HAPPY) while True: for speed in range(cutebot.MAX_SPEED): cutebot.set_motors_speed(speed, speed)
""" https://www.elecfreaks.com/learn-en/microbitKit/smart_cutebot/cutebot_case08.html In this case there are smaller speeds than in the official example. For me the Cutebot drives to fast to stay on the line-tracking map. """ from microbit import * import cutebot display.show(Image.HAPPY) while True: if not cutebot.has_left_track() and cutebot.has_right_track(): cutebot.set_motors_speed(30, 10) elif cutebot.has_left_track() and not cutebot.has_right_track(): cutebot.set_motors_speed(10, 30) elif cutebot.has_left_track() and cutebot.has_right_track(): cutebot.set_motors_speed(30, 30)