Ejemplo n.º 1
0
        life2.off()
        life3.off()
    elif lives == 0:
        life1.off()
        life2.off()
        life3.off()

lives = 3
life_counter(lives)

while True:
    time.sleep(0.01)
    for i in range(2):
        buzzer.on()
        time.sleep(0.5)
        buzzer.off()
        time.sleep(0.5)
    while lives > 0:
        time.sleep(0.01)
        tool.wait_for_press()
        for i in range(3):
            buzzer.on()
            time.sleep(0.2)
            buzzer.off()
            time.sleep(0.2)
        time.sleep(0.1)
        print("You lost a life")
        lives = lives - 1
        life_counter(lives)
    if lives == 0:
        print("Game Over")
Ejemplo n.º 2
0
        led.blink(0.05,0.05)
        bz.beep(on_time=0.1,off_time=0.1)
        print("Button pressed, taking photos...")
       
        #Take photos
        filename = "/home/pi/retropicam/photos/photo"
        
        #Take gif photos
        for num in range (length):
          date = time.strftime("%d-%m-%Y-%H-%M%S")
          takephoto = "fswebcam -r "+resolution+" --no-banner"+" "+filename+"-"+date+".jpg"
          os.system(takephoto)
     	#User feedback
        print("Photos Taken")
        led.off()
        bz.off()
        #makegif
        print("Making gif...")
        os.system("gm convert -delay 15 /home/pi/retropicam/photos/*.jpg /home/pi/retropicam/photos/gif.gif")
        
        #tweetgif
        print("Tweeting gif...")
        try:
	        photo = open('/home/pi/retropicam/photos/gif.gif','rb')
       		api.update_status_with_media(media=photo, status='A new Retrocam photo...')
       		print("Photo Tweeted!")
       	except:
       		print("Tweeting failed, check wifi.")
       		pass
       		
        #Tidy up
Ejemplo n.º 3
0
GPIO.setmode(GPIO.BCM)

GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)

#buzzer initialization
buzzer = Buzzer(16)
buzzerFlag = False
#buzzer.beep()
while True:
    input_state = GPIO.input(18)
    if input_state == False:
        print('Button Pressed 2')
        buzzerFlag = not buzzerFlag
        print "", buzzerFlag
        time.sleep(0.2)

    else:
        #print('Button not pressed')
        pass

    #Buzzer Active/Inactive
    if buzzerFlag:
        #print "Turning on Buzzer"
        buzzer.on()
        #buzzer.beep()
        sleep(1)
    else:
        #print "Turning off Buzzer"
        buzzer.off()
        #sleep(1)
mc.setBlock(x, y, z, block.GOLD_BLOCK.id)

#create LED
led = LED(4)

#create the buzzer
buzz = Buzzer(17)

#flash all the LED and buzz on
led.on()
buzz.on()

sleep(1)

led.off()
buzz.off()

dist = 0

gameover = False

while gameover == False:
    
    #get the players position now
    p = mc.player.getTilePos()
    
    #work out the distance between the player and the gold block
    xd = p.x - x
    yd = p.y - y
    zd = p.z - z
    dist_now = sqrt((xd*xd) + (yd*yd) + (zd*zd))
def space(x, y, rate):
    led = LED(x)
    buzz = Buzzer(y)
    led.off()
    buzz.off()
    sleep(rate * 3)
Ejemplo n.º 6
0
doubleClickThreshold = 0.3
longPressThreshold = 0.75

currentClickCount = 1
clickThread = None
releaseThread = None
isLongPress = False

r, g, b = background

keybow.setup(keybow.MINI)
keybow.set_all(r, g, b)
keybow.show()

bz = Buzzer(27)
bz.off()

i2c = io.I2C(board.SCL, board.SDA)
display = adafruit_ht16k33.segments.Seg7x4(i2c)
display.fill(0)

sensor = DistanceSensor(echo=15, trigger=14, max_distance=3)


@keybow.on(index=0)
def handle_key(index, state):

    if state:
        keybow.set_led(index, 255, 50, 50)
        keybow.show()
    else: