This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)
This instructable will cover the steps in order to recreate my project. My project was a rover that could follow a specific color or shape using a Pixy 2 and an Arduino Uno. All aspects of the process will be covered, including the necessary tools, assembly, control system and programming.
Step 1: Tools and Components
- Arduino Uno
- Pixy 2
- 2 x DC Motor
- DC Converter
- Pan-tilt Servo Kit
- 2 x 1N4001 diode
- 2 x 2N2222A transistor
- 2 x 1k resistor
- Aluminum T-Slotted Framing
- HDPE Plastic Sheet
- 2 x RC Car Tires
- 3D Printer
- USB 2.0 Cable
- Power drill/dremel
- Turnigy Multistar Multi-Rotor Lipo Pack
*Note: The objective of this project changed throughout the semester, so not everything was used as originally intended (the battery was overboard - you can achieve the same results with something much cheaper).
Step 2: Assembly
Unfortunately, I did not take many photos while assembling the project but it is not very difficult. The motor mounts as well as the pieces that held the battery onto the rails were 3D printed.
The t-slotted aluminum was screwed together with brackets into a rectangular form.
The black plastic sheets were drilling into and used to mount the: busbar, DC converter, breadboard, Arduino Uno and the Pixy 2. The Pixy 2 was mounted onto its own platform in order to give it a better viewing angle.
Step 3: Control System
The control system is fed by a 10000mAh lithium polymer battery that connects to a DC converter through a busbar. The battery is a lot larger than necessary, but it was purchased with the intention of using it for several different projects. The DC converter provides about 5V and through the breadboard, it powers the two DC motors as well as the Arduino Uno which, in turn, powers the Pixy 2.
Step 4: Electrical Schematics
Shown above is the basic breakdown of the wiring and electrical components. The transistor, an NPN 2N 2222A, is a semiconductor device utilized for low-power amplifying as well as switching applications. Diodes are used to keep current flowing in one direction, this protects the Arduino Uno from accidentally receiving the current and exploding. Because we are using DC motors, if for some reason it is going the wrong direction you can always just switch your power and ground cables and it will spin in the opposite direction. This cannot be done with AC motors. The pin configuration in the diagram does not correspond with the Arduino sketch, it only gives the user an idea of how the components are connected to each other.
Step 5: Arduino Sketch
The Arduino sketch for this project uses the Pixy 2 library, that can be found at pixycam.com under 'Support' and from there, 'Downloads'. Just make sure you download the appropriate library for either the Pixy or Pixy 2, respectively. While downloading the library, it is also very useful to download PixyMon v2. While the Pixy is able to learn colors/objects only by holding down the button and waiting for the LED to turn on (first white, then red) and releasing when red, it is helpful to teach it through the PixyMon program. You are also able to adjust all of the camera settings, including brightness and the minimum block area (this is useful if you are trying to detect smaller, bright hues). The sketch compares both areas as well as the x position of the detected object in order to follow whichever signature it is assigned. The Pixy 2 can learn up to seven different signatures and is able to detect hundreds of objects at a time.
From there, it is incredibly easy to program DC motors using the analogWrite() function, enabling the robot to go forward, left, or right.
Note: brighter, distinct hues work best with the Pixy
Step 6: Final Product
Here, the robot was taught to follow a red Christmas tree ornament.