View unanswered posts | View active topics It is currently Sat Sep 20, 2014 8:29 am






Reply to topic  [ 3 posts ] 
NXT won't display variable 
Author Message
Rookie

Joined: Fri Nov 29, 2013 12:12 pm
Posts: 14
Post 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)
{
}
}


Fri Dec 06, 2013 4:14 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post 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/

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Sat Dec 07, 2013 1:27 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: NXT won't display variable
Try this:
Code:
nxtDisplayTextLine(1, "Side=%s", (startingSide == left)? "left": "right");


Sat Dec 07, 2013 4:19 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.