Sep-29-2017, 03:17 AM
ok so this sample code is intended to run (at this time) infinetly until i re-run the code (f5)
my current problem is after i call the button function. i am attempting the first part of what will be an if elsif else statement to choose Longsound, Shortsound, or Medsound based on input. (the input will eventually be one of three buttons in a glove instead of 1, 2, or 3 on a keyboard, and eventually the random number will be transferred to the sound functions to pick one of 13 sound files(i was thinking something similar to a switch statement in C++) in each function.)
for now the if statement just to test to see if i can print long sound to the screen is not working
this will eventually be run on a raspberry pi.............. :(
it runs otherwise with no errors.
my current problem is after i call the button function. i am attempting the first part of what will be an if elsif else statement to choose Longsound, Shortsound, or Medsound based on input. (the input will eventually be one of three buttons in a glove instead of 1, 2, or 3 on a keyboard, and eventually the random number will be transferred to the sound functions to pick one of 13 sound files(i was thinking something similar to a switch statement in C++) in each function.)
for now the if statement just to test to see if i can print long sound to the screen is not working
this will eventually be run on a raspberry pi.............. :(
it runs otherwise with no errors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import random press = 0 def button(): press = input ( "enter\n" ) print ( 'pressed ' , press) return press def RNG(): #defnine random number generator x = 0 rnv = random.randint( 1 , 13 ) print ( 'Rnv is ' ,rnv) return rnv def Longsound(): #plays a long sound RNG() #calls random number generator print ( "longsound" ) print (RNG()) x = RNG() print ( "l" ,x, ".wav" ) def Shortsound(): #plays short sound RNG() print ( "shortsound" ) def Medsound(): RNG() print ( "mediumsound" ) def main(): print ( "\n\nhello world\n" ) press = button() print ( "main post button" ,press) if press = = 1 : #attempting to call (print the name) a function print ( "longsound" ) ''' main program run ''' while True : #loops program ill figure out how to exit and shutdown later main() #calls main program #if press == 1:#attempting to call (print the name) a function #print("longsound") |