elif value == 0x40:
     buildingbit.car_HeadRGB(255, 255, 255)
 # left
 elif value == 0x20:
     buildingbit.car_left(speed, 0)
 # buzzer
 elif value == 0xa0:
     music.pitch(698)
     sleep(400)
     music.stop()
 # right
 elif value == 0x60:
     buildingbit.car_right(speed, 0)
 # spinleft
 elif value == 0x10:
     buildingbit.car_spinleft(speed, speed, 0)
 # down
 elif value == 0x90:
     buildingbit.car_back(speed, speed, 0)
 # spinright
 elif value == 0x50:
     buildingbit.car_spinright(speed, speed, 0)
 # +
 elif value == 0x30:
     speed = speed + 40
     if speed > 255:
         speed = 255
         music.pitch(500)
         sleep(300)
         music.stop()
     else:
Ejemplo n.º 2
0
# -*- coding: utf-8-*-# Encoding cookie added by Mu Editor
from microbit import display, Image
import buildingbit

display.show(Image.HAPPY)

while True:
    sensorL = buildingbit.traking_sensor_L()
    sensorR = buildingbit.traking_sensor_R()
    if sensorL is False and sensorR is False:
        buildingbit.car_run(100, 100, 0)
    elif sensorL is False and sensorR is True:
        buildingbit.car_spinright(100, 100, 0)
    elif sensorL is True and sensorR is False:
        buildingbit.car_spinleft(100, 100, 0)
    else:
        buildingbit.car_stop()