LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

touch sensor

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 

0 Kudos
Message 1 of 13
(4,677 Views)

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?

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 13
(4,674 Views)

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.

0 Kudos
Message 3 of 13
(4,668 Views)

( 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 

0 Kudos
Message 4 of 13
(4,661 Views)

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.

 

untitled.JPG

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 5 of 13
(4,654 Views)

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.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 6 of 13
(4,653 Views)

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 

0 Kudos
Message 7 of 13
(4,634 Views)

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

0 Kudos
Message 8 of 13
(4,631 Views)

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.

0 Kudos
Message 9 of 13
(4,623 Views)

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.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 10 of 13
(4,614 Views)