Kremer VS-88A user guide and rs232 protocol
[veternica] / gumb.py
1 #!/usr/bin/env python
2
3 import time
4 import RPi.GPIO as GPIO
5 import pygame
6
7 def main():
8
9     # tell the GPIO module that we want to use the 
10     # chip's pin numbering scheme
11     GPIO.setmode(GPIO.BCM)
12     GPIO.setup(26,GPIO.IN, pull_up_down=GPIO.PUD_UP)
13     pygame.mixer.init()
14     pygame.mixer.music.load("/media/usb0/muzika.mp3")
15     odplayao = False
16     # setup pin 25 as an output
17
18 #    GPIO.setup(24,GPIO.OUT)
19 #    GPIO.setup(25,GPIO.OUT)
20
21
22 #    GPIO.output(25,True)
23
24     while True:
25         if GPIO.input(26):
26              # the button is being pressed, so turn on the green LED
27              # and turn off the red LED
28              #             GPIO.output(24,True)
29              #             GPIO.output(25,False)
30              #print "button false"
31              if odplayao == False:
32                 odplayao = True
33                 pygame.mixer.music.play()
34                 print('play')
35                 while pygame.mixer.music.get_busy() == True:
36                     continue
37         else:
38              odplayao = False
39              print "button true"
40              # the button isn't being pressed, so turn off the green LED
41              # and turn on the red LED
42 #            GPIO.output(24,False)
43 #            GPIO.output(25,True)
44 #            print "button false"
45
46              time.sleep(0.1)
47
48     print "button pushed"
49
50     GPIO.cleanup()
51
52
53
54 if __name__=="__main__":
55     main()