예제 #1
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
예제 #2
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")
예제 #3
0
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()
rocky.blue()
rocky.reflection_strength()
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)

rocky.forward(20, 2, straight = True)
rocky.forward(-20, 2, straight = True)