I designed this project for a 10-hour workshop for ChickTech.org whose goal is to introduce teenage women to STEM topics. The goals for this project were:
- Easy to build.
- Easy to program.
- Did something interesting.
- Low-cost so participants could take it home and continue to learn.
With those goals in mind, here were a couple of the design choices:
- Arduino compatible for ease of programming.
- 4xAA battery power for cost and availability.
- Stepper motors for accurate motion.
- 3D Printed for ease of customization.
- Pen plotting with Turtle graphics for interesting output.
- Open Source so you could make one of your own!
Here is the robot that came closest to what I wanted to do: http://mirobot.io. I don’t have a laser cutter and shipping from England was prohibitive. I do have a 3D printer, so I guess you can see where this is going . . .
Don’t let the lack of a 3D printer deter you. You can locate local hobbyists willing to help you out at https://www.3dhubs.com/.
It took a lot of work, but I’m please with how it turned out. And, I learned quite a bit in the process. Let me know what you think!
Step 1: Parts
There are a number of ways to power, drive, and control robots. You may have different parts on hand that will work, but these are the ones I’ve tried and found to work well:
- 1- *Adafruit Pro Trinket 3V- adafruit.com/products/2010
- 2- Geared 5V Stepper- adafruit.com/products/858
- 1- ULN2803 Darlington Driver – adafruit.com/products/970
- 1- Half-size breadboard- adafruit.com/products/64
- 16- Male-male jumpers- adafruit.com/products/759
- 1- Micro servo- adafruit.com/products/169
- 1 – SPDT slide switch – adafruit.com/product/805 or www.digikey.com/product-detail/en/EG1218/EG1903-ND/101726
- 1- Male pin header- digikey.com/short/t93cbd
- 2- 2 x AA Holder- digikey.com/short/tz5bd1
- 1- USB micro cable
- 4- AA Batteries
*Note: See the last step for a discussion on using regular Arduino or Raspberry Pi boards.
- 2- 1 7/8″ ID x 1/8″ O-ring- mcmaster.com/#9452K96
- 1- Caster 5/8″ bearing- mcmaster.com/#96455k58/=yskbki
- 10- M3 x 8mm pan head screw- mcmaster.com/#92005a118/=z80pbr
- 4- M3 x 6mm flat head screw- mcmaster.com/#91420a116/=yskru0
- 12- M3 Nut- mcmaster.com/#90591a250/=yskc6u
3D-Printed Parts (check out www.3dhubs.com if you don’t have access to a printer):
- 1 x Ball bearing caster – thingiverse.com/thing:1052674
- 1 x Chassis – thingiverse.com/thing:1053269
- 2 x Wheels – thingiverse.com/thing:862438
- 2 x Stepper bracket – thingiverse.com/thing:1053267
- 1 x Pen Holder / servo bracket – thingiverse.com/thing:1052725
- 1 x Pen Collar – thingiverse.com/thing:1053273
Tools and Supplies:
- Phillips screw driver
- Hot glue gun
- Digital multi-meter
- Sharp knife
- Crayola colored markers
Step 2: Flash the Firmware
Before we get too far into construction, lets load the test firmware on to the microcontroller. The test program just draws for boxes so we can check for proper direction and dimension.
To talk to the Trinket Pro, you are going to need:
- Driver from https://learn.adafruit.com/introducing-pro-trinket…
- Arduino software from https://learn.adafruit.com/introducing-pro-trinket…
Lady Ada and the Adafruit team have created a far better set of instructions in the links above than I can provide. Please use them if you are stuck.
Note: The one trick that makes the Trinket different from regular Arduino is that you have to reset the board before uploading the sketch.
Step 3: Pen Holder and Battery Holders
- Install the Pen Holder with the Servo Bracket on the shorter side of the chassis (Image 1).
- Insert the nuts on the top side of the chassis (Image 2)
- Attach the battery holders on the bottom of the chassis using 3Mx6mm flat-head screws (Images 3 & 4).
- Thread the battery leads through the rectangular cable runs (Image 4 & 5).
- Repeat for the other battery holder.
Note: Unless specified, the remainder of the screws are 3Mx8mm pan head srews.
Step 4: Wheels
- Test fit your wheel to the stepper shaft (Image 1).
- If it is too tight, you can heat the wheel hub with a hair drier or hot air gun and then insert the shaft.
- If it is too loose, you can use a 3Mx8mm screw to hold it against the flat of the shaft (Image 2).
- If you are a perfectionist, you can calibrate your printer and get it just right.
- Place the o-ring around the rim of the wheel (Image 3 & 4).
- Repeat for the other wheel.
Step 5: Stepper Brackets
- Insert a nut into the stepper bracket and attach them to the top of the chassis with a screw (Image 1).
- Insert the stepper into the bracket and attach with screws and nuts.
- Repeat for the other bracket.
Step 6: Caster
- Insert the ball bearing into the caster.
- Do not force it in or it will break. Use a hair-drier or hot air gun to soften the material if needed.
- Attach the caster to the bottom side of the chassis in front of the battery holder.
Step 7: Breadboard
- Remove one of the power rails using a sharp knife, cutting through the bottom adhesive (Image 1).
- Holding the breadboard over the chassis rails, mark where they intersect the edge (Image 2).
- Using a straight edge (like the removed power rail), mark the lines and cut through the backing (Image 3).
- Place the breadboard on the chassis with the rails touching the exposed adhesive (Image 4).
Step 8: Power
- Place the microcontroller, darlington driver, and power switch on to the bread board (Image 1).
- I’ve added orange dots for visibility to mark the following:
- Pin 1 of the darlington driver.
- The battery pin of the microtroller.
- The power switch “on” position.
- I’ve added orange dots for visibility to mark the following:
- With the right-hand battery leads:
- Connect the red line to the first pin of the power switch (Image 2).
- Connect the black lead to an empty row between the microcontroller and the darlington chip (Image 2).
- With the left-hand battery leads:
- Connect the red line to the same row as the black lead of the other battery (Image 3).
- Connect the black line to the negative rail of the breadboard (Image 3).
- Connect power to the microcontroller:
- Red jumper from positive rail to the battery pin (orange dot, Image 4).
- Black jumper from the negative rail to the pin marked “G” (Image 4).
- Install batteries and switch the power on. You should see the green and red lights of the controller come on (Image 5).
Troubleshooting: If the microcontroller lights do not come on, immediately turn the power off and troubleshoot:
- Batteries installed in the correct orientation?
- Double check battery leads positioning.
- Double check switch leads positioning.
- Use a multi-meter to check voltages of batteries.
- Use multi-meter to check power rail voltages.
Step 9: Headers and Servo wiring
Male header pins allow us to connect the 5-pin servo JST connectors to power and the darlington driver (Image 1):
- The first 5-pin header starts one row in front of the darlington driver.
- The second servo header should then line up with the end of the darlington driver.
Before the wiring gets to complicated, lets get the servo wired up:
- Add a 3-pin header for the servo on the right edge of the forward section of the breadboard( Image 2).
- Add a red jumper from the center pin to the positive side of the power rail.
- Add a black or brown jumper from the outer pin to the negative side of the power rail.
- Add a colored jumper from the inner pin to Pin 8 of the microcontroller.
- Install the servo horn with the shaft to the full clock-wise position and the arm extending to the right-side wheel (Image 3)
- Install the servo in the pen holder using the servo’s screws (Image 3).
- Connect the servo connector aligning the colors (Image 4).
Step 10: Stepper Control
Time to wire power for the darlington driver and steppers, which will be driven directly from the battery:
- Connect a black or brown jumper from the lower right darlington pin to the negative side of the power rail (Image 1).
- Connect a red jumper from the upper right darlington pin to the positive side of the power rail.
- Connect a red jumper from the upper left pin header to the positive side of the power rail (Image 2).
- Connect the left stepper connector to the left side pin header with the red lead on the right side (Image 3).
- Connect the right stepper connector to the right side pin header with the read lead on the left side.
Note: The red lead of the stepper connector is the power and should match the red leads on the breadboard.
Step 11: Stepper Control (Continued)
Now we will connect the stepper signal wires from the microcontroller to the input side of the darlington driver:
- Starting with Pin 6 of the microcontroller, connect the leads for four control jumpers for the left stepper motor (Image 1).
- Match these jumpers to the input side of the darlington on the right. All colors should match with the exception of green, which matches the pink wire of the stepper (Image 2).
- Starting with Pin 13 of the microcontroller, connect the leads for the four control jumpers for the right stepper motor (Image (3).
- Match these jumpers to the input side of the darlington on the left. All colors should match with the exception of green, which matches the pink wire of the stepper (Image 3).
Step 12: Testing and Calibration
Hopefully you already uploaded the firmware in Step 2. If not, do it now.
The test firmware just draws a square repeatedly so we can check direction and accuracy.
- Place your robot on a smooth, flat, open surface.
- Turn the power on.
- Watch your robot draw squares.
If you are not seeing lights on the microcontroller, go back and troublshoot power as in Step 8.
If your robot is not moving, double check the power connections to the darlington driver in Step 9.
If your robot is moving erratically, double check the pin connections for the microcontroller and darlington driver in Step 10.
If your robot is moving in an approximate square, it is time to put some paper down and put a pen in it (Image 1).
Your calibration points are:
float wheel_dia=66.25; // mm (increase = spiral out) float wheel_base=112; // mm (increase = spiral in) int steps_rev=128; // 128 for 16x gearbox, 512 for 64x gearbox
I started with a measured wheel diameter of 65 mm and you can see the boxes rotating inward (Image 2).
I increased the diameter to 67, and you can see it was rotating outward (Image 3).
I eventually arrived at a value of 66.25 mm (Image 4). You can see that there is still some inherent error due to gear lash and such. Close enough to do something interesting!
Step 13: Raising and lowering the pen
We’ve added a servo, but haven’t done anything with it. It allows you to raise and lower the pen so the robot can move without drawing.
- Place the pen collar on the pen (Image 1).
- If it is loose, tape it in place.
- Check that it will touch the paper when the servo arm is lowered.
- Check that it will not touch the paper when raised (Image 2).
The servo angles can be adjusted either by removing the horn and re-positioning it, or through the software:
int PEN_DOWN = 170; // angle of servo when pen is down int PEN_UP = 80; // angle of servo when pen is up
The pen commands are:
Step 14: Have Fun!
I hope you made is this far without too many curse words. Let me know what you struggled with so I can improve the instructions.
Now it is time to explore. If you look at the test sketch, you will see I have provided you some standard “Turtle” commands:
forward(distance); // millimeters backward(distance); left(angle); // degrees right(angle); penup(); pendown(); done(); // release stepper to save battery
Using these commands, you should be able to do just about anything, from drawing snow flakes or writing your name. If you need some help getting started, check out:
Step 15: Other Platforms
Could this robot be done with a regular Arduino? Yes! I went with the Trinket because of the low cost and small size. If you increase the chassis length, you can fit a regular Arduino on one side and the breadboard on the other (Image 1). It should work pin-for-pin with the test sketch, plus, you now can get to the serial console for debugging!
Could this robot be done with a Rasberry Pi? Yes! This was my first line of investigation because I wanted to program in Python, and be able to control it over the web. Like the full size Arduino above, you just place the Pi on one side, and the breadboard on the other (Image 2). Power becomes the primary concern because four AA is not going to cut it. You need to provide about 1A of current at a stable 5V, otherwise your WiFi module will stop communicating. I’ve found the Model A is much better on power consumption, but I’m still working out how to supply reliable power. If you figure it out, let me know!