Pi im Standard und Ausgabe verschönert

This commit is contained in:
starcalc 2022-02-27 15:32:47 +00:00
parent 17e0af3568
commit 833094a27d
1 changed files with 12 additions and 4 deletions

16
Pi/s.py
View File

@ -4,8 +4,8 @@ import serial
import pygame import pygame
serialmode=True #True for Raspberry Pi with Arduino connected, False for testing with keyboard serialmode=True #True for Raspberry Pi with Arduino connected, False for testing with keyboard
#serialport="/dev/ttyS0" # Raspberry Pi serialport="/dev/ttyS0" # Raspberry Pi
serialport="/dev/ttyUSB0" # serialport="/dev/ttyUSB0"
pygame.mixer.pre_init(buffer=32) pygame.mixer.pre_init(buffer=32)
pygame.init() pygame.init()
@ -89,13 +89,21 @@ while True:
Sound[i].stop() Sound[i].stop()
Sound[i].play() Sound[i].play()
Soundplaying[i]=True Soundplaying[i]=True
print("play "+str(i)) #print(str(i), end='')
i+=1 i+=1
else: #changed to 0 else: #changed to 0
if Soundplaying[i]: if Soundplaying[i]:
#Sound[i].stop() #Sound[i].stop()
Sound[i].fadeout(500) Sound[i].fadeout(500)
Soundplaying[i]=False Soundplaying[i]=False
print("stop "+str(i)) # print("stop "+str(i), end='')
for i in range(8):
if Soundplaying[i]:
print(str(i), end='')
else:
print(" ", end='')
print("", end='\r')
oldrcv = rcv oldrcv = rcv