def simon_game():
    initialize_arms()
    print "Connect servos"
    time.sleep(7)
    print "Ready"
    time.sleep(3)
    print "Go"

    red = mraa.Gpio(12)
    blue = mraa.Gpio(13)

    red.dir(mraa.DIR_OUT)
    blue.dir(mraa.DIR_OUT)

    result = simon.simon()

    if (result == False):
        red.write(1)
    else:   
        blue.write(1)

    time.sleep(4)
    red.write(0)
    blue.write(0)
    print "debugging:: simon game ends"
def user_play():
    initialize_arms()
    if record_user_performance:
        user_data = user_input_record(20)
        #sent it back to server
        send_http_post(serverIP, "usr_data=" + json.dumps(user_data))
        print "User data sent suceessfully"
    else:
        user_input(20)
    initialize_arms()
    print "debugging:: user mode ends"
def heartbeat_mode(time_interval):
    initialize_arms()
    pulse = False
    initial_time = time.time()
    while True:
        timestamp = time.time() - initial_time                     
        if (timestamp >= time_interval):
                print "heartbeat mode terminated."
                break
        output = hb.heartBeat(pulse)
        pulse = output[1]
        if (output[0] == True):
            print "heartbeat"
            play_note(False, 3, 0.1)
        time.sleep(0.01)
    initialize_arms()
    print "debugging::heartbeat_mode ends"
def robot_play(song, spb):
    initialize_arms()
    for note in song:
        play_note(False, note[0], note[1] * spb)
    initialize_arms()
예제 #5
0
import simon
import mraa
import time
import perceptive_layer as pl

pl.initialize_arms()
print "Connect servos"
time.sleep(7)
print "Ready"
time.sleep(3)
print "Go"

red = mraa.Gpio(12)
blue = mraa.Gpio(13)

red.dir(mraa.DIR_OUT)
blue.dir(mraa.DIR_OUT)

result = simon.simon()

if (result == False):
	red.write(1)
else:	
	blue.write(1)

time.sleep(4)
red.write(0)
blue.write(0)