|
Page 1 of 1
|
[ 3 posts ] |
|
NXT won't display variable
Author |
Message |
kkpanu9
Rookie
Joined: Fri Nov 29, 2013 12:12 pm Posts: 14
|
 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 |
|
 |
Ernest3.14
Professor
Joined: Sat May 18, 2013 1:24 pm Posts: 271 Location: Olympia, WA
|
 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 |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: NXT won't display variable
|
Sat Dec 07, 2013 4:19 am |
|
|
|
Page 1 of 1
|
[ 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
|
|