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!ย
HARDWAREย REQUIRED
All these 8 components are needed to make this robot.
SOFTWARE REQUIRED
ADDITIONAL INFORMATION
ย
ย
STEP BY STEP PREPARATION (HARDWARE)
ย
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
REFERENCES
ATTACHMENT
21 thoughts on “Colour Tracking Mobile Robot (PIXY)”
Hi, you can refer to the attachment (at the bottom post) for the sample code. Thanks.
i want to use pixy 2 for same could you please help me with code
how to write in coding if i want make 2color combine ? so that my robot will follow if these 2color combine detect only and not the single color. please help me for my final year project. in the pixyMon need to use ccsignature. but i cannot do in coding and the robot not move. if i use single color, the robot follow smoothly. but my problem is to use 2 color combine.
Hi Suadanwar,
May I want to know why you use1000?
Is it from the pixymon settings (max blocks per signature or just blocks)?
Why 1000?
Thank you
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?
the example code cant use…why….
hi….i program rdy but robot no move…why….
Hi, you may get the example code here.
Hi,you may get the example code here.
Hi…I buy this project rdy…but I don’t how to do programming to Arduino…pls help me…pls send me code…..
hi,
can u send code for colour tracking mobile robot…
nagarassitiren@gmail.com
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.
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,
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.
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 suadanwar.
okay. thanks for reply my message. good luck for your fyp.
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,
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,
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. 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??