LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I start/stop sounds in labview/from the NXT based on input from color sensors?

I'm working on a project for a robotics class in which I have a robot that uses a light sensor to follow a line, and two color sensors that detect different colors on the sides of the line. The robot would use the input of the two color sensors to determine a note to play (For example, if it detects purple in one sensor and purple in the second sensor, it will play a C). However, I can't figure out how to make the robot play the note once it detects to color, hold the note until the color changes, then play the next corresponding note. How can i make my robot play a note, hold it until it is no lnoger on the color corresponding to the note, then stop playing the note immediately after moving off of that color, with negligible delay times?

0 Kudos
Message 1 of 2
(5,190 Views)

Hi JPR7, 

There's a few ways you could go about doing this.  You can put a timer in your code to only allow the note to play for a certain amount of time before stopping.  You could also use a state machine with a timer to allow the note to play for a certain amount of time before returning to a silent state until it needs to play the next note.

 

Here is a link to an example of using a state machine in LabVIEW: https://decibel.ni.com/content/docs/DOC-3116 

Regards,
Kelly B.

National Instruments
0 Kudos
Message 2 of 2
(5,150 Views)