03-15-2012 08:40 AM
I want to use labview to program my NXT mindstorm touch sensor to continuesly play a sound when pressed once, it keeps playing the sound until pressed again, where it then plays another different sound continuesly, then when pressed for a third time it stop playing the sound file.
Any help would be much appreciated
Tim
03-15-2012 08:48 AM - edited 03-15-2012 08:50 AM
That's quite easy with the sound VIs and an event structure. Sounds like schoolwork though so I'll refrain from posting complete code.
What have you done so far???
EDIT: Easy with one caveat: I don't have the Mindstorm kit but I'm assuming it comes with LabVIEW VIs to interface it?
03-15-2012 09:23 AM
Thanks for the quick reply, haha no its not school work. Ive found event structures on tutorials etc but Ive only got the Mindstorm kit for Labview 2009 and it doesnt seem to come with that kit, is there another way of doing it? Ive messed around with case structures where I have a sound file played from the computer continuesly when the sensor is bumped but then cant seem to get it to stop playing or play another file when bumped again.
03-15-2012 10:23 AM
( I laughed because im a university masters student struggling to do what is apparantly school work standard labview programming 🙂 )
Ive found the events structure, but when trying to define events, I ahve not choice of vi s to chose from or anything? how can I add them to the selection?
thanks
Tim
03-15-2012 02:54 PM
If you don't have events you have to do it the old fashioned way, polling. You have a loop with a short time delay (~50mSec is good for UI response), put in a shift register, and then compare the control you want to monitor in the current loop iteration with the value from the last iteration.
03-15-2012 02:58 PM
In your case where you want to play a new sound file on each press you have many options. Probably the easiest is to increment an integer in another shift register and use that integer to index an array of sound file names. The new sound file path gets sent to the sound VI and it opens and plays.
03-16-2012 01:18 PM
Thanks for the help, I still cant seem to get it to work though. Heres what Ive done..Ive essentially tried to copy the image you posted, I cant seem to find the same T/F boolean image as you though.
Tim
03-16-2012 01:42 PM
attached wrong screen shot....so essentially its playing once when i press it, but i want it to keep playing until I press it again where it will either turn off or play a different sound file. How would I do this.
Thanks,
Tim
03-16-2012 02:50 PM
it also plays the sound file twice due to the fact that it is using the not equals function and the way it loops around therefore playing on both pressed and released conditions once.
03-16-2012 04:04 PM
OK, this is a good indicator for the need to study some of the basic LabVIEW tutorials (Google: Labview 101 tutorial)!
You have your loop control wired with a TRUE CONSTANT! It's set to stop when true (looks like a STOP sign) so your loop will only run once no matter what you do. Right-click that constant and change it to a control. Then your sound will toggle when you control the other boolean. The new STOP control will stop the VI.