Bukit Mertajam, Penang

Colour Tracking Mobile Robot (PIXY)

INTRODUCTION

Hi everyone, it seems that everyone nowaday love to build line following robots. So why don’t we try something new and adventurous? 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 we can make all this happen. Below is the step by step instruction to make this Colour Tracking Mobile Robot! 

Picture7

HARDWARE REQUIRED

All these 8 components are needed to make this robot.

ADDITIONAL INFORMATION

 

This latest version of CMUcam embedded camera is an programmable image sensor with a powerful processor that allows you to only send the information you’re looking for so your microcontroller isn’t overwhelmed by data from the image sensor. The Pixy CMUCam also exports its information in a variety of useful ways – UART serial, SPI, I2C, digital out, or analog out – so your microcontroller can do other tasks while communicating with the Pixy CMUCam. It’s so unobtrusive that you can even hook up multiple Pixy CMUCams to one microcontroller! Superb!
 
The Pixy CMUCam5 also uses hue and saturation as its primary means of image detection – rather than the normal RGB. This means that lighting or exposure won’t affect the Pixy CMUCam’s detection of an item – which is a frustrating problem with many other image sensors. It’s also a vast improvement over previous versions of the Pixy CMUCam, adding increased flexibility when it comes to lighting and exposure changes.
It can remember up to seven different color signatures, find hundreds of objects at the same time, and is super fast – processing at 50 frames a second.
 
Finally, the Pixy CMUCam is teachable so you can set it up to only send you images that you’ve specifically told it to look for. It’s easy, fast and has an open source application called PixyMon.
 
Each Pixy CMUcam5 Sensor comes with a 6-pin-to-10-pin IDC cable, mounting tabs and screws.

 

STEP BY STEP PREPARATION (HARDWARE)

1. First, set up the tires, motors, DC Jack (Male) and Battery holder to the

Aluminium robot chassis as shown in the Figure below.

 

 

2. Then, attach the CT-UNO to the aluminium robot chassis.

 

This is the wiring for the CT-UNO and Pixy CMUcam5.

 

3. Then, 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

robot hardware. 

 

STEP BY STEP PREPARATION (SOFTWARE)

1. First, we have to teach the Pixy the colours 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 chose 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.

CODE OVERVIEW

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.

while(millis()<=5000)
{
scan();
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. 

void scan()
{
uint16_t blocks;
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

(signature == 2)

You can change the number of signature that you have set by changing the number.

VIDEO

[vc_video link=”https://youtu.be/Ne6wLCIa1xs”]

Buy

[vc_cta h2=”” style=”flat” color=”white” add_button=”left” btn_title=”BUY THE PARTS” btn_color=”orange” btn_i_icon_fontawesome=”fa fa-opencart” btn_css_animation=”appear” css_animation=”appear” btn_add_icon=”true” btn_link=”url:https%3A%2F%2Fwww.cytron.com.my%2Fbundles%2Fcolour-tracking-mobile-robot-pixy||target:%20_blank|”][/vc_cta]

Related Posts

Comments (17)

hi suadanwar. im really interested in this project. i want to ask some questions.
1) can i use l293d because i dont have ct-uno
2) as you can see pixy can recognise more than1 colour. it is posibble that if we try to program 2 colour or more and every colour have it own instruction??

Hi adam4667,

Sorry for late reply. Based on your questions,
(1). L293D is a motor driver which in this robot I use 2Amp Motor Driver Shield as my motor driver. Motor driver and CT-UNO is two different things. CT-UNO is a microcontroller and it controls the robot. If you want to use L293D instead of CT-UNO, then the answer is NO. But if you want to use L293D instead of 2Amp Motor Driver Shield, then the answer is YES.

(2). Yes. You can program for more than one colour. Just make sure that the colour is Red,Orange,Yellow,Green,Cyan (light blue),Blue and Violet. Then you can just program it based on the number of the signature.

Hope you do understand my explaination. 🙂

hi suadanwar,
thanks for relpy my message.. i really need your help. now my project successful using your exactly your instruction and program. thank you so much suadanwar.

now i really want your help about add another 1 or 2 colour and every colour have its own instruction and modified the instruction using the program that you attach at source code..

thanks

adam4667@gmail.com

hi adam4667.

it’s good to hear that your project is successful by using the tutorial provided. 🙂 But you have to try it out yourself, I did this during my Intern 🙂 Now I am doing my own FYP and I do it myself and have no extra time to try it out for you. All the best to you 🙂

hi suadanwar.

okay. thanks for reply my message. good luck for your fyp.

Hi, if at all I used an l293d motor shield instead of the one you used, will there be any change in the code that you have provided?

Hi kafs,

You mean l293d ic right? You can still use the same coding, but you have to make sure that the pwm pin and motor pin of the l293d is similar with the coding.

1). hi, thank you for that insight… for the same project, have you attempted to use the pan and tilt servo mechanism as a camera stand..
2). as the robot approaches the object being tracked, is there a threshold distance to which the robot should not cross between it and the object or it goes all the way until it touches the robot?

Hi Kafs,
1. I didnt try to use the pan and tilt servo mechanism as a camera stand.
2. I just try and error with the threshold of the distance value.

hi,

can u send code for colour tracking mobile robot…

nagarassitiren@gmail.com

Hi…I buy this project rdy…but I don’t how to do programming to Arduino…pls help me…pls send me code…..

Hi,you may get the example code here.

Hi, you may get the example code here.

hi….i program rdy but robot no move…why….

the example code cant use…why….

Hey guys, currently, I am in my internshipsemester and I have to build a robot. This robot will be programmed by an arduino. It should have a PixyCam to track colors and a BLE shield to communicate with a mobile phone. Both are working with SPI. Do you think this will be an issue in my project?

Leave a comment

Get 7 Tips for Developing Electronic Projects
We respect your privacy.
Loading...