#import os
import serial
ser = serial.Serial(
- port='/dev/ttyAMA0',
- baudrate=9600,
- parity=serial.PARITY_NONE,
- stopbits=serial.STOPBITS_ONE,
- bytesize=serial.EIGHTBITS,
- timeout=0.1
+ port='/dev/ttyAMA0',
+ baudrate=9600,
+ parity=serial.PARITY_NONE,
+ stopbits=serial.STOPBITS_ONE,
+ bytesize=serial.EIGHTBITS,
+ timeout=0.1
)
ser.open()
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)
+ # GPIO.output(24,True)
+ # GPIO.output(25,False)
print "button false"
if trenutni==2:
- dobar = False
- trenutni=1
+ dobar = False
+ trenutni=1
while dobar!=True:
- print "poslao na matricu"
-# time.sleep(1)
- ON = "\x14\x82\x80\x81"
- ser.write(ON)
-# dobar=True
-# time.sleep(0.01)
- inp = ser.read(size=4)
- print inp.encode("hex")
- if inp.encode("hex") == "54828081":
- dobar=True
+ print "poslao na matricu"
+# time.sleep(1)
+ ON = "\x14\x82\x80\x81"
+ ser.write(ON)
+# dobar=True
+# time.sleep(0.01)
+ inp = ser.read(size=4)
+ print inp.encode("hex")
+ if inp.encode("hex") == "54828081":
+ dobar=True
pygame.mixer.music.play()
while pygame.mixer.music.get_busy() == True:
- continue
+ continue
else:
- print "button true"
+ print "button true"
if trenutni==1:
- dobar = False
- trenutni=2
+ dobar = False
+ trenutni=2
while dobar!=True:
- print "poslao na matricu"
- ON = "\x14\x81\x80\x81"
- time.sleep(1)
- ser.write(ON)
-# time.sleep(0.01)
- inp = ser.read(size=4)
- print inp.encode("hex")
- if inp.encode("hex") == "54818081":
- dobar=True
+ print "poslao na matricu"
+ ON = "\x14\x81\x80\x81"
+ time.sleep(1)
+ ser.write(ON)
+# time.sleep(0.01)
+ inp = ser.read(size=4)
+ print inp.encode("hex")
+ if inp.encode("hex") == "54818081":
+ dobar=True
time.sleep(0.2)