From: Dobrica Pavlinusic Date: Sun, 23 Jul 2023 09:22:37 +0000 (+0200) Subject: base gumb.py from other nodes X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=ba56864637ddb267a07d67e5d231e90c22ff3e58;p=veternica base gumb.py from other nodes --- diff --git a/1/gumb.py b/1/gumb.py new file mode 100755 index 0000000..d7785cb --- /dev/null +++ b/1/gumb.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +import time +import RPi.GPIO as GPIO +import pygame + +def main(): + + # tell the GPIO module that we want to use the + # chip's pin numbering scheme + GPIO.setmode(GPIO.BCM) + GPIO.setup(26,GPIO.IN, pull_up_down=GPIO.PUD_UP) + pygame.mixer.init() + pygame.mixer.music.load("/media/usb0/muzika.mp3") + odplayao = False + # setup pin 25 as an output + +# GPIO.setup(24,GPIO.OUT) +# GPIO.setup(25,GPIO.OUT) + + +# GPIO.output(25,True) + + while True: + if GPIO.input(26): + # the button is being pressed, so turn on the green LED + # and turn off the red LED + # GPIO.output(24,True) + # GPIO.output(25,False) + print "button false" + if odplayao == False: + odplayao = True + pygame.mixer.music.play() + while pygame.mixer.music.get_busy() == True: + continue + else: + odplayao = False + # print "button true" + # the button isn't being pressed, so turn off the green LED + # and turn on the red LED + # GPIO.output(24,False) + # GPIO.output(25,True) + # print "button false" + + time.sleep(0.1) + + print "button pushed" + + GPIO.cleanup() + + + +if __name__=="__main__": + main()