<< return to Pixycam.com

Pixy2 Line Following question

Hello, I am a novice guy with Pixy2 and I wanted to know how I could modify the Line Follower program.

I would like my robot to follow a line and curve according to where a green square is positioned on the path.

Where can I find examples or tutorials where I can program the PixyCam?

PS: I use Arduino for controll the motors of the robot

The Line Follower program doesn’t interpret colors (unfortunately). It does however interpret barcodes, which might work for your application. If you want to interpret colors, you would need to switch between the Color Connected Components program and Line Follower program over and over again, which would slow things down quite a bit.

You might check out this page:


Sorry, but Can I write a own program for PixyCam that can follow the line and can interpret colors at the same time?

You can, but you need to run 2 different programs (Line Tracking" and “Color Connected Components” using changeProg()

So your program would look similar to this:

void loop()
  int8_t res;

  // grab blocks!
  if (pixy.ccc.numBlocks)
    // use ccc data...

  res = pixy.line.getMainFeatures();
  if (res<=0) 
    // use line data...

Hope this helps!


Hi there, have you had any success with coding this task? I am looking to do the same. Cam this program switching occur only when the green square is detected and then go back to line following?
Thank you