LabVIEW for LEGO MINDSTORMS and LabVIEW for Education

Showing results for 
Search instead for 
Did you mean: 

Need some help on a nxt project

Go to solution

Right now im trying to make it work on RobotC. I know that this subforum is about coding on Labview but i can't find an answer for my problem =/

I'm working on a project and i really need some help to understand how lego-temp.h works. I want to make a while loop so i can measure the temperature while the robot is moving. The loop will stop when i'll find a temperature higher than the temperature that i have before the robot started moving.

I found out that i can read a temperature with that command --> LEGOTMPreadTemp(S2,temp);

This command is reading from the sensor 2 , my temperature sensor, and writes the result on a variable called temp.

My problem is that i can't find how can i read the temperature while the robot is moving.U can find the lego-temp.h on \Sample Programs\NXT\3rd Party Driver Library\include but i will post it as a link if u can't find it.

Thanks for ur time 😄

0 Kudos
Message 1 of 9
Accepted by RaizO_

Hey RaizO,


While I am not familiar with RobotC I think it might be helpful to see more code. If you are able to get temp readings using the code you posted then that might not be the problem. My guess would be that in the greater context of the project, when the robot is moving it doesn't get to the temperature reading part of the code.




Sam J.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 9

The question is that while moving the robot you need to be able to have a parallel loop that reads something else.

Or in your moving loop spend time (while waiting or so) read the temp.


Where parallel programming is easy in LabVIEW it is one of the big problems in C.

greetings from the Netherlands
0 Kudos
Message 3 of 9

Thank u for your reply!

Well i tried one more time to create the code on lego mindstorms ev3. The problem that i can't measure while the robot is moving is still there. I figured another way to make it kinda work. I programmed the robot to to make small moves just to find a candle. 
I'll post what i did with some screenshots.
Some guy on a forum advised me to create a code with 2 start blocks but i couldn't make it work. 

0 Kudos
Message 4 of 9

You need to set two while loops in parallel.

Meaning they don't have wires connected except for initializing and after the while where they can come together to close.

All loops that are not via via connected run in parallel.

This is in fact LabVIEW with a Mindstorm shell, so the same parallelism applies.

I don't have an EV3 but an older version, less capable and at the moment no software loaded but I can guarantee that what you want is possible.

greetings from the Netherlands
0 Kudos
Message 5 of 9

I don't have EV3 either. I'm working on NXT but i had a problem setting up the temperature sensor block on mindstorms NXT so i used the EV3 program. About the two while loops what should run inside them. When i tried to code with two starts and two while loops i had on the first the movement blocks and on the other the switch statements (ultrasonic,touch and temperature).

0 Kudos
Message 6 of 9

From my head after about 12 year not programming in mindstorms, so be careful.

start outside the loops and lead the reference to both loops!


greetings from the Netherlands
0 Kudos
Message 7 of 9

Well i tried to do that but it didn't work =/ 
Don't know what im doing wrong.

0 Kudos
Message 8 of 9

First try a simplified version

Just moving a big enough distance and measuring temperature, and make sure that no wires go from one loop to the other loop.



greetings from the Netherlands
0 Kudos
Message 9 of 9