the NXTSketch program
The NXTSketch program that you’ll create in this section will use the line-drawing feature of the Display block to turn the TriBot into a sketch pad; the TriBot’s two wheels control where the line is drawn. The program is fairly simple: It repeatedly draws a line from the last point used to the location defined by the current value of the two Rotation Sensors.
The NXTSketch program uses two variables, X and Y, to store the last location used. Both variables are initialized to zero at the beginning of the program. The Rotation Sensors are read in a loop to get the new location, with the B motor used for the new X value and the C motor used for the Y value. Finally, a line is drawn from the old location to the new location, ...
Get The Art of LEGO MINDSTORMS NXT-G Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.