ROBOTC.net forums
http://robotc.net/forums/

NXT won't display variable
http://robotc.net/forums/viewtopic.php?f=52&t=7414
Page 1 of 1

Author:  kkpanu9 [ Fri Dec 06, 2013 4:14 pm ]
Post subject:  NXT won't display variable

I made some code to tell my robot which side to be on. On the display it is supposed to say "starting side" and next to it either "left" or right" based on if I press the left or right button respectively on the NXT. For some reason when I ran the program everything worked except it would not display the word "left" or "right" on the NXT. It does recognize when I press the left or right button on the NXT, and it changes the variable to left or right, but it just doesn't display it on the NXT. I changed the code a little bit, but I am not sure if it will fix it. Do you see any problem with the code?


typedef enum
{
left,
right,
} Side;

Side startingSide = left;
void setStartingSide();

task sideButtonTask()
{
nSchedulePriority = kHighPriority;
switch (nNxtButtonPressed)
{
case kLeftButton:
startingSide = left;
nxtDisplayTextLine(1, "Side", startingSide);
break;
case kRightButton:
startingSide = right;
nxtDisplayTextLine(1, "Side", startingSide);
break;
default:
break;
}
return;
}

void setStartingSide()
{
nNxtButtonTask = sideButtonTask;
nxtDisplayTextLine(1, "startingSide", startingSide);
while (nNxtButtonPressed != kEnterButton)
{
}
}

Author:  Ernest3.14 [ Sat Dec 07, 2013 1:27 am ]
Post subject:  Re: NXT won't display variable

When you use the function "nxtDisplayTextLine", you have to leave a space in the text for what variable you want to display. See this reference: http://www.cplusplus.com/reference/cstdio/printf/ (<- not all of the listed modifiers work in RobotC)
Xander also wrote a nice intro here: http://botbench.com/blog/2013/03/31/out ... in-robotc/

Author:  MHTS [ Sat Dec 07, 2013 4:19 am ]
Post subject:  Re: NXT won't display variable

Try this:
Code:
nxtDisplayTextLine(1, "Side=%s", (startingSide == left)? "left": "right");

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/