Example #1
0
def on_button_a_pressed():
    codey.speaker.play_melody('hello.wav')
    while True:
        rocky.forward(50)
        if rocky.color_ir_sensor.is_obstacle_ahead():
            codey.speaker.play_melody('wrong.wav', True)
            rocky.backward(50, 1, straight=True)
            rocky.turn_left_by_degree(90)
            rocky.forward(50, 2, straight=True)
Example #2
0
def on_button2_callback():
    global rage, t
    if rage > random.randint(3, 5):
        rage = 0
        time.sleep(0.5)
        codey.display.show_image('00003c1e0e0400000000040e1e3c0000')
        rocky.backward(20, 0.4)
        rocky.backward(100, 0.01)
        rocky.forward(100, 0.2)
        rocky.backward(100, 0.01)
        time.sleep(0.1)
        codey.speaker.play_melody('angry.wav')
        time.sleep(0.5)
        codey.display.show_image('00003c7e7e3c000000003c7e7e3c0000')

    else:
        time.sleep(0.5)
        codey.display.show_image('00081c3c3c3820000020383c3c1c0800')
        time.sleep(0.5)
        codey.speaker.play_melody('sad.wav')
        codey.display.show_image('00040e1e1e1c100000101c1e1e0e0400')
        rocky.backward(50, 0.1)
        codey.display.show_image('00081c3c3c3820000020383c3c1c0800')
        time.sleep(0.3)
        codey.display.show_image('00183c3c7c7820000020787c3c3c1800')
        time.sleep(0.1)
        codey.display.show_image('00003c7e7e3c000000003c7e7e3c0000')
        rage = (rage
                if isinstance(rage, int) or isinstance(rage, float) else 0) + 2
Example #3
0
def rocky_send():
    print("rocky forward")
    rocky.forward(100, 2)
    print("rocky back")
    rocky.backward(100, 2)   
    print("rocky left")    
    rocky.turn_left(100, 2)
    print("rocky right")
    rocky.turn_right(100, 2)
    print("rocky stop")
    print("rocky set rgb color white")
    rocky.color("#ffffff")
    time.sleep(1)
    print("rocky set rgb color red")
    rocky.color("#ff0000")
Example #4
0
def on_button1_callback():
    global rage, t
    if rage > random.randint(3, 5):
        rage = 0
        time.sleep(0.5)
        codey.display.show_image('00003c1e0e0400000000040e1e3c0000')
        rocky.backward(20, 0.4)
        rocky.backward(100, 0.01)
        rocky.forward(100, 0.2)
        rocky.backward(100, 0.01)
        time.sleep(0.1)
        codey.speaker.play_melody('angry.wav')
        time.sleep(0.5)
        codey.display.show_image('00003c7e7e3c000000003c7e7e3c0000')

    else:
        time.sleep(0.4)
        codey.display.show_image('000c18181c0c000000000c1c18180c00')
        codey.speaker.play_melody('laugh.wav')
        rocky.turn_right(70, 0.05)
        codey.display.show_image('00183030381800000000183830301800')
        rocky.turn_left(70, 0.05)
        codey.display.show_image('000c18181c0c000000000c1c18180c00')
        rocky.turn_right(70, 0.05)
        rocky.turn_left(70, 0.05)
        time.sleep(0.3)
        codey.display.show_image('00183030381800000000183830301800')
        time.sleep(0.1)
        codey.display.show_image('00003c7e7e3c000000003c7e7e3c0000')
        rage = (rage
                if isinstance(rage, int) or isinstance(rage, float) else 0) + 1
Example #5
0
codey.is_shaked()
codey.is_tilt('forward')
codey.sound_strength()
codey.light_strength()
codey.dail()
codey.gyro('pitch')
codey.time()
codey.reset_time()
codey.ir_send("A")
codey.ir_receive()

print("***codey APIS all succeed***")
# about rocky
rocky.color("#334455")
rocky.forward(50, 1)
rocky.backward(50, 1)
rocky.turn_left(50, 1)
rocky.turn_right(50, )
rocky.forward(50)
rocky.backward(50)
rocky.turn_left(50)
rocky.turn_right(50)
rocky.drive(50, 50)
rocky.turn_left_angle(15)
rocky.turn_right_angle(15)
rocky.stop()

rocky.is_obstacle_ahead()
rocky.is_color('red')
rocky.red()
rocky.green()
import codey
import rocky
import time
import event


rocky.forward(20)
time.sleep(1)
rocky.forward(-20)
time.sleep(1)
rocky.backward(-20)
time.sleep(1)
rocky.backward(20)
time.sleep(1)
rocky.turn_left(20)
time.sleep(1)
rocky.turn_left(-20)
time.sleep(1)
rocky.turn_right(-20)
time.sleep(1)
rocky.turn_right(20)
time.sleep(1)

rocky.forward(20, 1)
rocky.forward(-20, 1)
rocky.backward(-20, 1)
rocky.backward(20, 1)
rocky.turn_left(20, 1)
rocky.turn_left(-20, 1)
rocky.turn_right(-20, 1)
rocky.turn_right(20, 1)