import buildingbit import music import neopixel display.off() np = neopixel.NeoPixel(pin16, 3) np.clear() buildingbit.init_IR(pin8) buildingbit.car_run(0, 0, 0) speed = 100 a = 0 while True: # print(hex(buildingbit.get_IR(pin8))) value = buildingbit.get_IR(pin8) value = value >> 8 # default if value == -0x01: a = a + 1 if (a > 3): buildingbit.car_stop() a = 0 # long pressed elif value == 0xff: a = 0 else: # off if value == 0x00: buildingbit.car_HeadRGB(0, 0, 0)
# -*- coding: utf-8-*-# Encoding cookie added by Mu Editor from microbit import display, pin8, sleep import buildingbit import music display.off() buildingbit.init_IR(pin8) buildingbit.car_run(100, 100, 0) music.pitch(226) sleep(300) music.pitch(0) while True: # print(hex(buildingbit.get_IR(pin8))) value = hex(buildingbit.get_IR(pin8)) if value == "-0x1": buildingbit.car_run(0, 0, 0) elif value == "0xffff": buildingbit.car_run(0, 0, 0) else: value = value[0:4] if value == "0xff": music.pitch(226) sleep(300) music.pitch(0) elif value == "0x80": music.pitch(226) sleep(300) music.pitch(0) elif value == "0x40":