Exemplo n.º 1
0
def main(argv):
    ohbot.reset()
    ohbot.move(2, 7, 1)  # eyes
    ohbot.wait(0.5)

    while 1:
        head_tracking_move()
Exemplo n.º 2
0
def main():
    items = [
        '/ohbot-python/examples/Fart.wav',
        '/ohbot-python/examples/Scary_Scream.wav',
        '/ohbot-python/examples/Demon_Girls_Mockingbird.wav'
    ]

    ohbot.reset()
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(8, GPIO.IN,
               pull_up_down=GPIO.PUD_DOWN)  #Read output from PIR motion sensor
    GPIO.setup(10, GPIO.IN,
               pull_up_down=GPIO.PUD_DOWN)  #Read output from BUTTON sensor
    play_sound(items[1])
    get_steven_to_talk()
    play_sound(items[1])
    play_random_sound(items)
    start_time = time.time()
    elapsed_time = time.time() - start_time

    while True:

        PIR = GPIO.input(8)
        BUTTON = GPIO.input(10)
        print(PIR)
        print(BUTTON)

        if (PIR == 1):  #When output from motion sensor is High
            print("Elapsed time: %n", elapsed_time)
            if elapsed_time > 59:
                play_sound(items[1])
                get_steven_to_talk()
                play_sound(items[1])
                start_time = time.time()
                elapsed_time = time.time() - start_time
            else:
                elapsed_time = time.time() - start_time

        if (BUTTON == 1):
            play_random_sound(items)

        time.sleep(0.1)
Exemplo n.º 3
0
#module level variable to stop it going off twice
lastm = ""


#this is called on a separate thread to blink the eyes while running
def blinkLids():
    while (blinking):
        ohbot.move(ohbot.LIDBLINK, 0)
        sleep(0.2)
        ohbot.move(ohbot.LIDBLINK, 10)
        #wait for a random amount of time for realistic blinking
        sleep(randint(0, 4))


#start up sequence resets to mid position, sets the eyes to blue then goes to sleep
ohbot.reset()
ohbot.eyeColour(0, 0, 10)
sleep(1.0)
ohbot.eyeColour(0, 0, 0)
ohbot.move(ohbot.HEADNOD, 0)
ohbot.move(ohbot.LIDBLINK, 0)
sleep(2.0)
#close to turn the motors off
ohbot.close()

while (True):
    #get seconds and minutes into strings
    s = strftime("%S", localtime())
    m = strftime("%M", localtime())
    #set this to False for testing to make Ohbot speak continuously
    everyQuarterHour = True
Exemplo n.º 4
0
def get_steven_to_talk():
    """Run the Ohbot routine
    Returns:
        Boolean True or False depending on whether run successfully or not
    """

    try:
        # Reset Ohbot

        ohbot.reset()

        # Switch the speech synthesizer to epseak
        ohbot.setSynthesizer("espeak")

        # Set the voice to english West Midlands accent medium speed.

        ohbot.setVoice("-ven+f2 -s130")

        # Set eyes to red
        ohbot.eyeColour(10, 0, 0)

        ohbot.wait(0.5)

        # Say something
        ohbot.say("Good Evening", True, False, False, 0)
        ohbot.wait(0.5)
        #ohbot.say("Who have we got here",True, False, False,0)
        #ohbot.wait(0.5)
        ohbot.say("I'm the late great Mary Webb ", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("I love children ", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("For supper", True, False, False, 0)
        ohbot.wait(0.5)
        #ohbot.say("Woooahhhh woooahhha",True, False, False,0)
        #ohbot.wait(0.5)
        # Wait a few seconds for the motors to move

        ohbot.wait(2)

        # Move head left to right
        ohbot.move(ohbot.HEADTURN, 4, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADTURN, 6, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADTURN, 5, 1)
        ohbot.wait(0.5)
        ohbot.eyeColour(0, 10, 0)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADNOD, 7, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.HEADNOD, 1, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.EYETURN, 9, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.EYETURN, 1, 1)
        ohbot.wait(0.5)
        ohbot.move(ohbot.EYETURN, 5, 1)
        ohbot.wait(0.5)
        ohbot.say("Take one sweet.", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("At your own risk", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("Don't forget to brush your teeth", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.say("Happy Halloween", True, False, False, 0)
        ohbot.wait(0.5)
        ohbot.reset()
        # close ohbot at the end.
        ohbot.wait(0.5)
        ohbot.close()
        ohbot.wait(0.5)
        return True
    except:
        return False
Exemplo n.º 5
0
def on_closing():
    ohbot.reset()
    ohbot.wait(1)
    ohbot.close()
    win.destroy()