Exemplo n.º 1
0
def limit_change():
    global flag
    if microbit.button_a.is_pressed():
        superbit.motor_control(superbit.M1, -255, 0)
        flag = 0
        display.show(Image.ARROW_S)

    elif microbit.button_b.is_pressed():
        superbit.motor_control(superbit.M1, 255, 0)
        flag = 1
        display.show(Image.ARROW_N)
Exemplo n.º 2
0
    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.HAPPY)
radio.on()
radio.config(group=1)
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, -100, 0)
        superbit.motor_control(superbit.M3, 100, 0)
    elif incoming == 'right':
        superbit.motor_control(superbit.M1, 100, 0)
        superbit.motor_control(superbit.M3, -100, 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')
Exemplo n.º 3
0
from microbit import *
import superbit
import microbit

display.show(Image.HAPPY)

while True:
    superbit.motor_control(superbit.M1, 255, 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, 120)

while True:
    music.play('E4:4')
    superbit.servo270(superbit.S1, 60)
    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, 180)
    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)
Exemplo n.º 5
0
from microbit import *
import music
import superbit
import neopixel

zero = Image("09990:90009:90009:90009:09990")
one = Image("00900:09900:00900:00900:09990")
two = Image("99900:00090:00900:90000:99990")
tree = Image("99990:00090:00900:90090:09900")
four = Image("00990:09090:90090:99999:00090")
five = Image("09999:09000:09990:00009:09990")

flag = 0
superbit.motor_control(superbit.M1, 0, 0)
np = neopixel.NeoPixel(pin12, 4)


def limit():
    global flag
    if flag > 5:
        flag = 5
    elif flag < 0:
        flag = 0


def change():
    global flag
    if button_a.is_pressed():
        music.play(music.POWER_UP)
        flag = flag + 1
    elif button_b.is_pressed():
Exemplo n.º 6
0
from microbit import *
import superbit
import microbit
display.show(Image.HAPPY)

while True:
    superbit.motor_control(superbit.M1, 0, 0)
    superbit.motor_control(superbit.M3, 0, 0)
    microbit.sleep(1000)
    superbit.motor_control(superbit.M1, 125, 0)
    superbit.motor_control(superbit.M3, 125, 0)
    microbit.sleep(1000)
    superbit.motor_control(superbit.M1, 255, 0)
    superbit.motor_control(superbit.M3, 255, 0)
    microbit.sleep(1000)
    superbit.motor_control(superbit.M1, 125, 0)
    superbit.motor_control(superbit.M3, 125, 0)
    microbit.sleep(1000)
Exemplo n.º 7
0
from microbit import *
import superbit
import radio
import neopixel

radio.on()
radio.config(group=1)

display.show(Image.HEART)

np = neopixel.NeoPixel(pin12, 4)

while True:
    incoming = radio.receive()
    if incoming == 'up':
        superbit.motor_control(superbit.M2, 255, 0)

    elif incoming == 'down':
        superbit.motor_control(superbit.M2, -255, 0)

    elif incoming == 'left':
        superbit.motor_control(superbit.M4, 180, 0)

    elif incoming == 'right':
        superbit.motor_control(superbit.M4, -180, 0)

    elif incoming == 'stop':
        superbit.motor_control(superbit.M1, 0, 0)
        superbit.motor_control(superbit.M2, 0, 0)
        superbit.motor_control(superbit.M3, 0, 0)
        superbit.motor_control(superbit.M4, 0, 0)
Exemplo n.º 8
0
from microbit import *

import microbit
import superbit

display.show(Image.HAPPY)
a = 0


def limit_change():
    global a
    if microbit.button_a.is_pressed():
        a = a + 50
        if a > 255:
            a = 255
    if microbit.button_b.is_pressed():
        a = a - 50
        if a < 0:
            a = 0
    return


while True:
    limit_change()
    superbit.motor_control(superbit.M1, a, 0)
    sleep(500)