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.



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! 




All these 8 components are needed to make this robot.





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.





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. 





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.




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.

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.



  1. Quick Start
  2. Hooking up Pixy to a Microcontroller like an Arduino


Sample Source Code


21 thoughts on “Colour Tracking Mobile Robot (PIXY)”

  1. 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.

  2. Muhammad Fahmi Bin Rosnan

    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

  3. 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?

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

  5. 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.

  6. 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?

  7. 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.

  8. 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?

  9. 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 🙂

  10. 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..



  11. 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. 🙂

  12. 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??

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
DIY Automated Vacuum Cleaner Using REKA:BIT With Micro:bit
Rainbow Spark in Mini House using Maker Uno.
TinyML on Arduino using Edge Impulse
Tutorials of Cytron Technologies Scroll to Top