Hi everyone, it seems that everyone nowadays love to make a line following robot. Why don’t we try something new and adventure? Why don’t we try to make a robot that follow the colour that we want? It can be red, orange, yellow, blue, green, light blue and violet. By using a Pixy CMUcam5 and CT-UNO you can make all this happen. Below is the step by step instruction to make this Colour Tracking Mobile Robot comes true!!
All this 8 component is needed to make this robot.
STEP BY STEP PREPARATION (HARDWARE)
1. Firstly, you have to setup the tires, motors, DC Jack (Male) and Battery holder to the
Alluminium robot chassis as shown in the Figure below.
2. Then, you can attach the CT-UNO to the alluminium robot chassis.
This is the wiring for the CT-UNO and Pixy CMUcam5.
3. Then, you can stack the 2Amp Motor Driver Shield to CT-UNO.
4. Put the 3.7V 1100mAh Li-Ion battery to the batery holder.
5. Lastly, attach the Pixy CMUcam5 sensor to the robot. Now we are finished setup the
STEP BY STEP PREPARATION (SOFTWARE)
1. Firstly, we have to teach the Pixy the colour that we want it to remember. Run PixyMon after it’s connected to the computer by using USB cable. Click Action and choose Set signature. (I choose Set signature 2 for my orange colour)
2. Now the video camera will stop and show the capture image. From this image you can teach the camera the colour that you want by choose the region that you want.
3. Now Pixy already memorize the colour and will recognize it as s=2 because we set it to signature 2.
4. We have to tune the colour so that Pixy will only capture the colour that we want. This can be done by clicking on the gear icon. Just slide it to the left if we want it to be less inclusive and to the right if we want it to be more inclusive.
5. After tuning the Pixy, now we can proceed with arduino. Please make sure that the library file is added to the arduino library. We can try the sample code hello_world by Pixy after we added the library. Just click on File -> Example -> Pixy -> hello_world. Then, just upload the source code. After that, click on serial monitor and you will see the image below. On the serial monitor, it will print the height, width and signature.
This source code will do scan() function for 5 seconds. You can change the time by changing the 5000 to the value that you want.
[code lang=”c” highlight=””]
area = width * height; //calculate the object area
maxArea = area + 1000;
minArea = area – 1000;
Below shows the coding for scan() function as mentioned in while loop above.
[code lang=”c” highlight=””]
blocks = pixy.getBlocks(); //receive data from pixy
signature = pixy.blocks[i].signature; //get object’s signature
x = pixy.blocks[i].x; //get x position
y = pixy.blocks[i].y; //get y position
width = pixy.blocks[i].width; //get width
height = pixy.blocks[i].height; //get height
In the void loop() function, there is mention
[code lang=”c” highlight=””](signature == 2)[/code]
You can change the number of signature that you have set by changing the number.