SparkFun will be closing early at 3:30 Friday 5/27 and remain closed Monday for Memorial Day (5/30). Orders placed after 2pm MT on Friday (5/27) will process and ship out on Tuesday (5/31).
The ProtoSnap Minibot is designed to be a low-cost introduction to robotics for hobbyists, students and educators. It is Arduino-compatible and the ProtoSnap architecture means that when you've exhausted the potential of the kit as-is, you can break it apart and use the components to make other robots.
First off, a warning to those who may not be familiar with the ProtoSnap line -- don't break the board apart yet! The Minibot is designed to use the PCB as a structural element of the design and if you break it apart, well, that's not very structural, is it?
You'll need some basic soldering skills to assemble the kit, and basic Arduino programming skills to use it. Once you've assembled it (using the included direction booklet), you can program it to navigate mazes, avoid objects, or map a room. By adding some extra parts, you can make it a line follower, add remote control, or do just about anything else you can imagine!
The Minibot kit comes with all the parts you need to build the robot:
You'll also need a few tools to finish the assembly:
The Minibot board is broken into seven sections: a power/prototyping area, a motor driver, an Arduino Uno-compatible Pro Mini, an FTDI basic, two infrared reflective object detection sensor areas and another small prototyping area.
We'll start at the front of the board and work our way back. The object detection sensors are placed at a 45° angle to the direction of travel to provide directional object detection. The code loaded on the board is set to calibrate out ambient light, then look for objects too close to the front of the robot and attempt to avoid them by backing away and turning in the opposite direction. When assembled, the emitter sits flush with the board surface, while the receiver sits above and behind the emitter to avoid crosstalk between the two, which could affect results.
Between the two object detection sensors you'll find an additional prototyping area. Normally, the center hole is used for the standoff/screw combination which supports the front end; however the two holes to either side of that one are positioned to accept the Tamiya ball caster, which we sell. They can also be used with additional standoffs to mount downward-looking infrared sensors for line-following applications.
The next two sections are an Arduino Uno-compatible 5V Pro Mini and an FTDI Basic, which allow you to upload your code to the onboard Atmega328P at the higher speeds supported by the Optiboot bootloader. The chip is running at 5V with a 16MHz oscillator, and all of the standard pins you'd expect from a full-size Arduino board are pulled out, albeit in a smaller footprint. The connections to the motor controller, infrared LEDs and infrared sensors are pre-routed, so you don't have to make any of those connections on your own.
Behind that section is a motor driver based on the TB6612FNG chip. The motor drive voltage is preset to 4.5V; there is a spot for a through-hole resistor on the board which allows the user to adjust that voltage up or down for future applications. There are also .1" spaced headers for all of the relevant power and control signals, as well as .156" spaced holes for screw terminals (not included) for the motor outputs and power supply connections.
The last and largest section is the power supply and prototyping area. The battery cradle mounts to the pads provided here, as does the motor, and the row of pads closest to the battery along either side is tied to a single bus. These pads are perfect for attaching headers to provide tie points for external sensors, stepper motors, or other circuits you may want to add to the robot.
You can download the full .ino file here.
Minibot ships with a very simple example program -- it calibrates the light sensors to ambient, then drives the robot forward until it detects an object. When an object is detected, the robot backs away from the object and turns to avoid running into it again, then starts off forward again.
The code is intended to provide an example of how to interface the motor driver and how to read the sensors, as well as to provide raw material to save end users' time in creating redefinitions for all of the pin connection signals. It is not intended to be a terribly useful application -- after all, where's the fun in that?
We start with the pin redefinitions. By redefining our pin numbers to something a little more user-friendly, we improve the readability of the code. I prefer "#define" to "const int" but either method will work. Next, I define a delay for the time between turning an LED on and scanning the input; that's not necessary but I've found (experimentally) that it does seem to improve behavior.
We'll also set up some global variables for the detect and clear levels -- these are values populated during the calibration process. The idea of using a different level for detection than for clear is called "hysteresis." If we were to only back up enough to drop the light level to the point where it triggers an object detection, we may not go far enough to clear the object, and we'd trigger another detection right away upon resuming motion. The detect and clear offsets are the values used by the calibration function to determine the values for the detect and clear levels. I'll get to that in a moment.
Now we're into the meat of the code: the setup() and loop() functions. You'll note that I abstracted most everything into a function call; that makes it easier to reuse my code in your applications later. setup() is pretty minimal. Enable the serial port for debugging, call a function, which configures the pins as inputs and outputs as necessary, make sure the motors are stopped, then calibrate the sensors. I'm going to skip pinSetup() altogether and driveStop() for now; let's take a look at how sensorCal() does its thing.
sensorCal() makes a couple of big assumptions: first, that the robot is in a relatively open area when it comes up from power off or reset, and second, that the ambient light will remain more or less the same during operation. Both of these are things that can be handled by more robust code; that's an exercise for the reader. The initial code simply turns on the LED, takes a reading of the light level, then sets the "detect" threshold to be a delta of 20 percent from that value and the "clear" threshold to be when the value returns to within 5 percent of the ambient level. It's worth noting at this point that as the reflected light level increases, the analog value on the pin actually DECREASES rather than the other way around. Thus, detection occurs at 80 percent of nominal, and clear occurs at 95 percent of nominal. A significant increase in ambient light level may cause spurious detections to be triggered.
In the loop() code, we drive forward at half speed and check the sensors every 100ms or so (as defined by "PING_RATE").
By the precalibration of the light levels we've done, detecting a bump is as simple as checking to see if analogRead() returns a value below the established threshold. Then we turn away from the object until we get close to the ambient level.
Finally, a few words on the control methods for the motor driver. I've implemented a few functions: forward and reverse for left and right motors, forward and reverse for BOTH motors, and stop and brake functions for each motor and for both motors. The functions for both motors simply call the left and right versions; if one were to call leftFwd() after calling driveFwd(), that would have no impact on the operation of the right motor. Additionally, it is important to understand the difference between "stop" and "brake." Stop simply disconnects the drive from the motor -- the robot may continue to coast for some time. Brake actively connects the two poles of the motor to ground, effectively turning the motor into a generator with an extremely large load. The result is that the motors will come to a halt much more quickly.
Hopefully this is enough information to get you started playing with your new Minibot! Over the coming weeks we'll be adding more tutorials and information about hacking the Minibot for remote control, to add extra sensors, and more. We also plan to offer additional courses on Minibot through the education department, so keep your eyes open for that! We've given you the robot, now show us what you can do with it!