
I'm trying to create a script with a loop for my Wall.E. to monitor two button sensors wired to the ADC0 via resistors on an ioTiny. I want my script to continuously loop and if either ADC value range is encountered a specific sound file will play.
The script behavior that I get that I don't want is, which ever button I press, I then I have to press the other button before my script will respond. I want to be able press button1 as many times as I want and have the sound file play and or press button2 as many times and have the sound file play. I don't want to have to press buton1 > then button2 > then button1.....or conversely button2 > then button1 > then button2.
I know it's not hardware because I see in the ADC Value control change correctly with the value sitting at 1 when nothing is pressed. It shows around 230 for the value with a press of button1 and a value of around 211 when pressing button2
What does it look like I'm doing wrong in my script?Code:
:ReadSensors
#Button1
if(ADC_Wait_Between( 0, 220, 250 ))
controlCommand("Soundboard v4", "Track_6")
endif
#Button2
if(ADC_Wait_Between( 0, 200, 217 ))
controlCommand("Soundboard v4", "Track_18")
endif
Goto(ReadSensors)
I think I remember this being discussed here a few years ago and I think someone came up with a way to do this. I just can't remember.
A simpler solution would be to use two different ADC ports if you have one available.
Hope this works for you. If you have a momentary button you may have to keep the button pushed until the script starts.Code: