All finished! It took a bit longer than expected (I’ve been tinkering around with some final upgrades and fine tuning for the past few days), but now, at last, it’s working! Check out this video I shot of PriNXT (clever name, I know) yesterday when it was drawing the epically awesome WilsonTech1:
Since this is a pretty long post, I’ve split it up into a few sections for you: Hardware/ Design, Image Processing, Programming, and Conclusion. How considerate of me.
Hardware/ Design – Motors
PriNXT has three motors: two control the X and Y motion, and the third lifts the pen.
The first motor, the one in the middle, is very straight forward – it has two long axes coming out of it that connect to two tiny gears that can drive around on a series of gear racks, moving the contraption about the Y axis. The second and third motor are a bit more complex, since they both point inward and have to move their power around a lot.
The left one, which controls motion on the X axis, basically just gears its power to a really long row of worm wheels, which, when spun, slowly move the part that holds the pen from left to right. The third motor similarly transfers its power to the outside, after which it moves a long rod up and down, pulling the pen along with it no matter where it is. For more details, see PriNXT’s very own Hardware Post.
Hardware/ Design – Sensors
The robot has a total of four sensors: two touch, one light, and one color.
The touch sensors serve the simple purpose to calibrate the robot – it blindly drives towards them until it registers that they’re pressed, which tells PriNXT where to start drawing. The color sensor is used as a signal light to show that the robot has finished calibrating.
The light sensor, only added two days ago, is used for moving the pen, which has actually been one of the hardest parts of this project. Because the beam that moves the pen up and down is slightly flexible, it had to be slightly higher or lower depending on how far to the right the pen was. When the pen would move, this would cause conflicts, so now, instead of being static, the pen now continuously moves up and down a bit to compensate for this movement. The light sensor guides it in this, reading its position and telling it to either go higher or lower.
For the design part, I mostly kept this project in my usual red/ white/ shades of gray color scheme, which I’m actually starting to enjoy using more and more.
Image Processing
A big part of PriNXT was to get it to draw complex shapes and pictures like the one in the picture below.
So this is how it works: first, I import the image into Paint.NET, where I make it black and white, and then edit it a bit to get a better looking result. Then, I export it as a .PBM file, which basically turns the whole picture into a bunch of 1′s and 0′s. Then, I import those 1′s and 0′s into NotePad++, where I reformat them to something my program will understand. Finally, I copy the results into a pre-made array in RobotC, fill in the height and width of gthe image, and I’m done!
For a more detailed description on how to do this, and on how to use this method to display detailed images on your NXT, see this post here: How To: Display Images on Your NXT using RobotC (JPEG, PNG, etc.)
Programming
Mostly, the code for PriNXT consists of the following (in order):
- Calibration functions for the X and Y motors, which basically drive them both backwards until they hit their respective touch sensors, and then reset their encoders
- A “moveLinear” function, which very niftily calculates the amount of degrees needed to get to the user specified position, and then calculates speeds for both that allow it to go there in a straight line (if one motor has to move a lot more than the other motor, the other motor slows itself down to help it keep up)
- A “movePen” function, which.. moves the pen up and down
- A “drawBinaryImage” function, which draws the image according to the 1′s and 0′s I copy into its 2D “imageToDraw” array using two for loops, one inside the other
- A “controlPen” task, which keeps the pen at the right height even when the “movePen” function is not called
- The main task, which controls the rest
Conclusion
So yeah, I really enjoyed doing this project, even if it was challenging at times. For even moar pictures and other stuff my robot printed, check out my Google Plus profile (heck, you could even circle me)
And yes, it also drew the text in the header. Go ahead, scroll up and take a look at it :)



First, open the “Adjustments” menu and click “Black and White.” Then, again in the “Adjustments” menu, open “Brightness/ Contrast,” and, in the wizard that pops up, set the contrast to 100.












