PixyCam2 - Giving Your Project Eyes
2023-11-17 | By Antonio Velasco
When working on projects, something that can be an extremely useful tool is a sensor that detects if an item is there or not. Commonly, people will use an IR sensor or Ultrasonic sensors that just detect obstacles, but for items of further distance or a specific color, something like a PixyCam2 would be more beneficial.
What is a PixyCam2?
Created by the bright minds at Charmed Labs and Carnegie Mellon University, PixyCam2 is an electronics component that acts as a sensor for your project. It’s essentially a mini camera mounted onto a PCB that processes what it sees and returns it as data in the form of position or area of a specific color that it sees. This means that the PixyCam2 can detect colors, how far they are, and how big they are on an object.
Here’s the User-Interface for the PixyCam2:
Notice how the boxes center around a specific color? Each pixel within the camera's view is categorized as a certain color and will show up if you train the camera to detect it. You can train the camera to detect certain colors or edit the camera view through the settings on the top bar.
Each signature is a color to look for. The CC signature is if you want to use a specific hexcode. It’s also notable to mention that you can detect multiple colors at the same time. Whenever the camera detects a color that it’s looking for, a light will flash on the PCB.
Additionally, the field of view of the PixyCam2 acts as a big grid, meaning that you can get the area of each “box” to get a relative idea of how far it is (if the box is smaller) or how close it is (if the box is bigger). You can also get the relative position of it (if it is more left or more right, up or more down, etc.). The grid systems look like this:
How Can I Utilize a PixyCam2?
To utilize the PixyCam2, you’ll need a microcontroller and a programming device (like a laptop) to set it up. The Arduino IDE doesn’t have the support to show live videos or configure the PixyCam2, so the first application that you should get is the PixyMon V2 download, which you can find on the PixyCam website. The icon should look like this:
Using the USB cable that came with your PixyCam, you can connect it to your computer.
Within the PixyMon app, you can now see what your PixyCam sees and set Signatures (Action -> Set Signature __), which are colors that the PixyCam will look for. There are also example programs under Programs for you to use. Play around with it and get a feel for how the PixyCam sees the world, and once you’ve set your parameters, be sure to save it (File -> Save Parameters). You can then load it back up under the same menu.
The PixyCam2 is compatible with the Arduino UNO pins as it comes with a special cable to plug it in. Additionally, you can use the USB cable to plug it into a Raspberry Pi easily. If you don’t have either, there are a number of interfaces (UART, I2C, SPI) within it to allow you to get any controller working with it.
Potential Projects
Something cool about the PixyCam2 is that it is always detecting or searching for those specific colors. This means that you can easily have it track an object, even if your project is moving. Something I made is an Autonomous Rover in my freshman engineering class that will track a pink can and follow it. It utilizes the PixyCam2 to detect the pink can and turn accordingly. I used PID control (see this blog!) to control its turns.
I’ve been thinking of a few more projects to use it on, like a laser pointer that will follow a brightly colored balloon or something that’ll collect data on how many cars are certain colors. Of course, both will take a lot of calibration and work, but just some fun ideas to throw out there. Another cool thing could be for sorting or counting Lego Bricks to see how much of each color you might have. It'd be a lot faster than just counting it out one by one.
To say the least, the possibilities are limitless with this tool in your arsenal. The PixyCam2 provides eyes for your projects and gives it a way to interact with and look at the world. It’s easy to use and provides a world of opportunity.
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum