def run_L(): display.show(show_L) global b if b == 1: sleep(1000) tinybit.car_run(speed_run) sleep(1000) tinybit.car_spinleft(speed_spin) sleep(400) tinybit.car_run(speed_run) sleep(1000) tinybit.car_stop() global b b = 0
def run_Z(): display.show(show_Z) global b if b == 1: sleep(1000) tinybit.car_run(speed_run) sleep(1000) tinybit.car_spinright(speed_spin) sleep(500) tinybit.car_run(speed_run) sleep(1300) tinybit.car_spinleft(speed_spin) sleep(600) tinybit.car_run(speed_run) sleep(1300) tinybit.car_stop() global b b = 0
# -*- coding: utf-8-*-# Encoding cookie added by Mu Editor # from microbit import * from microbit import display, sleep, pin8, pin12 import tinybit import music import neopixel np = neopixel.NeoPixel(pin12, 2) np.clear() tinybit.car_HeadRGB(0, 0, 0) tinybit.init_IR(pin8) tinybit.car_stop() display.off() speed = 100 a = 0 music.play('c') while True: # print(hex(tinybit.get_IR(pin8))) value = tinybit.get_IR(pin8) value = value >> 8 # default if value == -0x01: a = a + 1 if (a > 3): tinybit.car_stop() a = 0 # long pressed