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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access