Sei sulla pagina 1di 11

ROBOTC PROGRAMMING 4.

NXTBRICK AND DISPLAY

D-r.Ramona Markoska, ass.prof.


TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

4.1. NXT brick and Display


4.1.1.Display
100 pixels wide and 64 pixels high. monochrome 2 States for each pixel: on, off. The bottom left corner is point (0, 0) and the top right corner of the display is point (99, 63). There are eight text lines numbers 0 to 7. 0 is the top line and 7 is the bottom line of the display

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

4.1.2. Simple Programming Example


Exercice.1. Displays the words "Hello World !" on the NXT display for 9 seconds and exits. (introduction to the details of writing, saving, compiling, and running a program) Main meni Main function ( first section of instructions to Program windows:
be executed)

({, }) enclose a block of instructions.


3

first instruction is a call to the function nxtDisplayString()

first argument, 3, species the line on which to place the words after.

second instruction is a call to the wait1Msec() function. Argument - (1 millisecond = 1/1000th of a second) specied in its argument before proceeding to the next instruction in this case 9,000 milliseconds (or 9 seconds) before proceeding. MECHATRONIC SYSTEMS

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

Exercice.1 Compile and Save

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

Exercice.1. 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.

On the NXT Display go to My Files->Software Files->HelloWorld ! HelloWorld Run.


TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

4.2. NXT Functions for Display (1)


ROBOTC has a rich set of functionality for drawing text and shapes on the LCD screen
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.

Syntax
eraseDisplay(); or nxtClearPixel(xPos, yPos); nxtDisplayClearTextLine(nLineNum);

nxtDisplayBigStringAt(xPos, yPos, sFormatString, parm1, parm2);

int printMe=1; int printMeToo=2;

nxtDisplayBigStringAt( 15, 15, %d, %d, printMe, printMeToo);

nxtDrawCircle(Left, Top, Diameter);


nxtDrawEllipse(Left, Top, Right, Bottom);

Draws outline of the circle with the specified coordinates


Draws outline of the ellipse with the specified coordinates. Draws a line between two points.

nxtDrawCircle(10, 20, 18);


nxtDrawEllipse(10, 20, 56, 25);

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

MECHATRONIC SYSTEMS

3.2. NXT Functions for Display (2)


ROBOTC has a rich set of functionality for drawing text and shapes on the LCD screen 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

Syntax
nxtDrawRect(10, 50, 60, 25);

nxtEraseEllipse(), nxtEraseLine(), nxtEraseRect(), nxtFillEllipse(), nxtFillLine(), nxtFillRect(),

nxtInvertLine(xPos, yPos, xPosTo, yPosTo); nxtScrollText(sFormatString, parm1, parm2);

Shift the LCD image up one for(i=0; i<1000; ++i) { line. nxtScrollText("Scroll #%d.", i); wait1Msec(250); } Boolean variable that indicates whether the top status line display on the LCD should be present on user-drawn LCD screens. bNxtLCDStatusDisplay = true; (The NXT top status line WILL display on user-drawn LCD screens.)

bNxtLCDStatusDisplay

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

*** More display commands are available in the RobotC On-line Support on the left sidebar under the NXT Functions->Display section.

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

TEMPUS IV Project: 158644 -JPCR Development of Regional Interdisciplinary Mechatronic Studies DRIMS

MECHATRONIC SYSTEMS

Potrebbero piacerti anche