Professional Documents
Culture Documents
RobotC-4 T.M. Ramona
RobotC-4 T.M. Ramona
ROBOTC PROGRAMMING
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
4.1.1.LCD Display
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
Function
eraseDisplay(); nxtClearPixel(); nxtDisplayClearTextLine();
Semantic
Erases the complete NXT LCD display, or Clears a single pixel on the NXT LCD screen. Erases a line of text. 'nLineNum' specifies one of the 8 possible text lines
Formats a text string and displays it at any (X,Y) coordinate on the LCD display. Drawing uses a large font that is 16-pixels high. 'sFormatString' is the format string to use and 'parm1' and 'parm2' are two optional parameters that can be used within the format string. Draws outline of the circle with the specified coordinates Draws outline of the ellipse with the specified coordinates. Draws a line between two points.
Syntax
eraseDisplay(); or nxtClearPixel(xPos, yPos); nxtDisplayClearTextLine(nLineNum);
int printMe=1; int printMeToo=2; nxtDisplayBigStringAt( 15, 15, %d, %d, printMe, printMeToo);
nxtDrawCircle(Left, Top, Diameter); nxtDrawEllipse(Left, Top, Right, Bottom); nxtDrawLine(xPos, yPos, xPosTo, yPosTo);
nxtDrawLine(20, 50, 60, 25); ( Draw line betweeb A(20,50) and B(60,25)
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
Function
nxtDrawRect(Left, Top, Right, Bottom);
Semantic
Draws outline of the rectangle with the specified coordinates. Erase something between gived borders or points. Solid Fill something between gived borders or points Inverts the pixels for the given line Shift the LCD image up one line.
Syntax
nxtDrawRect(10, 50, 60, 25);
nxtEraseEllipse(), nxtEraseLine(), nxtEraseRect(), nxtFillEllipse(), nxtFillLine(), nxtFillRect(), nxtInvertLine(xPos, yPos, xPosTo, yPosTo); nxtScrollText(sFormatString, parm1, parm2);
for(i=0; i<1000; ++i) { nxtScrollText("Scroll #%d.", i); wait1Msec(250); } bNxtLCDStatusDisplay = true; (The NXT top status line WILL display on user-drawn LCD screens.)
bNxtLCDStatusDisplay
Boolean variable that indicates whether the top status line display on the LCD should be present on user-drawn LCD screens.
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
For Loop from 0 to 12 incrementing 'i' by 1 each time: Display "Scroll #i." (%d is replaced with variable 'i' at runtime.) Wait 200 milliseconds between each iteration of the For Loop.
ROBOTC PROGRAMMING
***
More display commands are available in the RobotC On-line Support on the left side-bar under the NXT Functions->Display section.
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
and exits.(introduction to the details of writing, saving, compiling, and running a program) Main function ( first section of instructions
Program windows: to be executed)
first argument, 3, species the line on which to place the words after.
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
second instruction is a call to the wait1Msec() Argument - (1 millisecond = 1/1000th of a second) specied in its function. argument before proceeding to the next instruction in this case 9,000 milliseconds (or 9 seconds) ROBOTC PROGRAMMING before proceeding.
. 4.3.1.Code Execution:
1.Compile
2.Save
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
. 4.3.1.Code Execution: Turn on the NXT brick and connect it to the USB port of the
computer. Under the main menu, choose Robot-> Compile and Download Program.
ROBOTC PROGRAMMING
(20,36) and (20,20) are (X,Y) pixel coordinates on NXT Display. (Y2-Y1=36-20= 16 pixel font)
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
. Code 4.3.2.
This example is tested using Compiler Target, Virtual Worlds.. This example is tested using Compiler Target, Virtual Worlds. It is not recommended after option Compile Program, to use Lego Virtual Worlds Table. That's because all programming activity can be presented on NXT Brick Display. For that purpose, it is necessary to use Debugger Windows menu and NXT Remote Screen, where results wil be presented. On next page, on the footer of picture, a compiler window is presented. This is the place where are posted messages in case of some errors in process of debugging .
ROBOTC PROGRAMMING
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
Discusion, Questions ?
Use of LCD Display ? How important is it ? NXT Brick functions ? Compiler target and Remote Screen functionality ?
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING
References
www.robotc.net http://www.doc.ic.ac.uk/~ajd/Robotics/RoboticsResources/ http://greenarmyrobotics.org/robotc/introduction-to-the-robotcdebugger Albert W. Schueller (2011), Programming with Robots, Whitman College http://www2.cs.siu.edu/~hexmoor/classes/CS404-S10/Wahl.pdf http://reference.kfupm.edu.sa/content/r/probot_programming_environ ments_52469.pdf
TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS
ROBOTC PROGRAMMING