superbit.motor_control(superbit.M3, 255, 0) elif incoming == 'right': superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, 0, 0) elif incoming == 'stop': superbit.motor_control(superbit.M1, 0, 0) superbit.motor_control(superbit.M3, 0, 0) elif incoming == 'turn_off': np.clear() np.show() elif incoming == 'R' and flag == 0: RGBLight_more_show(0, 4, 'Red') angle = angle - 5 if angle < 60: angle = 60 superbit.servo270(superbit.S1, angle) incoming = radio.receive() if incoming == 'R': flag = 1 elif incoming == 'G': RGBLight_more_show(0, 4, 'Green') superbit.servo270(superbit.S1, 60) elif incoming == 'B': RGBLight_more_show(0, 4, 'Blue') superbit.servo270(superbit.S1, 240) elif incoming == 'Y' and flag == 0: RGBLight_more_show(0, 4, 'Yellow') angle = angle + 5 if angle > 240: angle = 240 superbit.servo270(superbit.S1, angle)
while True: incoming = radio.receive() if incoming == 'up': superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, 255, 0) elif incoming == 'down': superbit.motor_control(superbit.M1, -255, 0) superbit.motor_control(superbit.M3, -255, 0) elif incoming == 'left': superbit.motor_control(superbit.M1, 0, 0) superbit.motor_control(superbit.M3, 255, 0) elif incoming == 'right': superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, 0, 0) elif incoming == 'stop': superbit.motor_control(superbit.M1, 0, 0) superbit.motor_control(superbit.M3, 0, 0) elif incoming == 'R': RGBLight_more_show(0, 4, 'Red') superbit.servo270(superbit.S1, 60) elif incoming == 'G': RGBLight_more_show(0, 4, 'Green') superbit.servo270(superbit.S1, 120) elif incoming == 'B': RGBLight_more_show(0, 4, 'Blue') elif incoming == 'Y': RGBLight_more_show(0, 4, 'Yellow') superbit.servo270(superbit.S1, 180)
from microbit import * import superbit display.show(Image.HAPPY) superbit.servo270(superbit.S1, 90) while True: if button_a.is_pressed() is True and button_b.is_pressed() is False: superbit.servo270(superbit.S1, 0) elif button_a.is_pressed() is False and button_b.is_pressed() is True: superbit.servo270(superbit.S1, 90)
def RGBLight_more_show(first, num, color): global np np.clear() for i in range(first, first + num): np[i] = color_lib[color] np.show() np = neopixel.NeoPixel(pin12, 4) display.show(Image.HEART) radio.on() radio.config(group=1) superbit.servo270(superbit.S1, 105) while True: incoming = radio.receive() if incoming == 'up': superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, 255, 0) elif incoming == 'down': superbit.motor_control(superbit.M1, -255, 0) superbit.motor_control(superbit.M3, -255, 0) elif incoming == 'left': superbit.motor_control(superbit.M1, -255, 0) superbit.motor_control(superbit.M3, 255, 0) elif incoming == 'right': superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, -255, 0)
from microbit import * import superbit import microbit import neopixel np = neopixel.NeoPixel(pin12, 4) fan = Image("00990:90900:99999:00909:09900") display.show(fan) global a, b, angle angle = 135 b = 0 superbit.servo270(superbit.S1, angle) microbit.sleep(1000) while True: superbit.motor_control(superbit.M1, 225, 0) if b == 0: superbit.servo270(superbit.S1, angle) angle = angle + 1 if angle > 270: angle = 270 b = 1 elif b == 1: superbit.servo270(superbit.S1, angle) angle = angle - 1 if angle < 0: angle = 0 b = 0
from microbit import * import music import superbit import microbit import neopixel display.show(Image.HAPPY) np = neopixel.NeoPixel(pin12, 4) superbit.servo270(superbit.S1, 90) while True: music.play('E4:4') superbit.servo270(superbit.S1, 70) superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, 255, 0) np[0] = (255, 0, 0) np.show() music.play('E4:4') superbit.servo270(superbit.S1, 50) np[1] = (0, 255, 0) np.show() music.play('F4:4') superbit.servo270(superbit.S1, 30) np[2] = (0, 0, 255) np.show() music.play('G4:4') superbit.servo270(superbit.S1, 10) np[3] = (255, 255, 0) np.show() music.play('G4:4') superbit.servo270(superbit.S1, 0)
from microbit import * import microbit import superbit display.show(Image.HEART) while True: x = accelerometer.get_x() x1 = ((x+1024)*(225-45)/2048)+45 x1 = int(270 - x1) superbit.servo270(superbit.S1, x1) microbit.sleep(20)
from microbit import * import superbit display.show(Image.HAPPY) superbit.servo270(superbit.S1, -0) while True: if button_a.is_pressed() is True and button_b.is_pressed() is False: superbit.servo270(superbit.S1, 0) elif button_a.is_pressed() is False and button_b.is_pressed() is True: superbit.servo270(superbit.S1, 60)
from microbit import * import music import superbit import microbit import neopixel display.show(Image.HAPPY) np = neopixel.NeoPixel(pin12, 4) superbit.servo270(superbit.S1, 120) while True: music.play('E4:4') superbit.servo270(superbit.S1, 240) superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, 255, 0) np[0] = (255, 0, 0) np.show() music.play('E4:4') superbit.servo270(superbit.S1, 120) superbit.motor_control(superbit.M1, 255, 0) superbit.motor_control(superbit.M3, 255, 0) np[1] = (0, 255, 0) np.show() music.play('F4:4') superbit.servo270(superbit.S1, 240) superbit.motor_control(superbit.M1, -255, 0) superbit.motor_control(superbit.M3, -255, 0) np[2] = (0, 0, 255) np.show() music.play('G4:4') superbit.servo270(superbit.S1, 120)
from microbit import * import superbit import microbit import random superbit.servo270(superbit.S1, 50) microbit.sleep(500) superbit.servo270(superbit.S1, 140) display.scroll("Go!") def Face_show(): global a a = random.randint(1, 7) if a == 1: display.show(Image.HAPPY) elif a == 2: display.show(Image.ANGRY) elif a == 3: display.show(Image.SMILE) elif a == 4: display.show(Image.CONFUSED) elif a == 5: display.show(Image.SAD) elif a == 6: display.show(Image.HEART) while True: superbit.servo270(superbit.S1, 50) microbit.sleep(200)
'White': White } def RGBLight_more_show(first, num, color): global np np.clear() for i in range(first, first + num): np[i] = color_lib[color] np.show() np = neopixel.NeoPixel(pin12, 4) display.show(Image.HEART) superbit.servo270(superbit.S1, 135) radio.on() radio.config(group=1) while True: incoming = radio.receive() if incoming == 'up': superbit.motor_control(superbit.M1, 255, 0) if incoming == 'down': superbit.motor_control(superbit.M1, -255, 0) elif incoming == 'stop': superbit.motor_control(superbit.M1, 0, 0) elif incoming == 'R': RGBLight_more_show(0, 4, 'Red') superbit.servo270(superbit.S1, 0) elif incoming == 'G':
from microbit import * import microbit import superbit display.show(Image.HEART) superbit.servo270(superbit.S1, 0) superbit.servo270(superbit.S2, 0) superbit.servo270(superbit.S3, 0) superbit.servo270(superbit.S4, 0) microbit.sleep(1000) while True: superbit.servo270(superbit.S1, 0) superbit.servo270(superbit.S2, 0) superbit.servo270(superbit.S3, 0) superbit.servo270(superbit.S4, 0) microbit.sleep(1000) superbit.servo270(superbit.S1, 90) superbit.servo270(superbit.S2, 90) superbit.servo270(superbit.S3, 90) superbit.servo270(superbit.S4, 90) microbit.sleep(1000) superbit.servo270(superbit.S1, 180) superbit.servo270(superbit.S2, 180) superbit.servo270(superbit.S3, 180) superbit.servo270(superbit.S4, 180) microbit.sleep(1000) superbit.servo270(superbit.S1, 270) superbit.servo270(superbit.S2, 270) superbit.servo270(superbit.S3, 270) superbit.servo270(superbit.S4, 270)
from microbit import * import superbit display.show(Image.HEART) superbit.servo270(superbit.S1, 0) sleep(1000) while True: if button_a.is_pressed(): superbit.servo270(superbit.S5, 60) elif button_b.is_pressed(): superbit.servo270(superbit.S5, 0)