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

Hello,
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:
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:pixy_zumo_howto

Edward

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

Hello,
You can, but you need to run 2 different programs (Line Tracking" and “Color Connected Components” using changeProg()
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api

So your program would look similar to this:

void loop()
{ 
  int8_t res;

  pixy.changeProg("color");
  // grab blocks!
  pixy.ccc.getBlocks();
  if (pixy.ccc.numBlocks)
  { 
    // use ccc data...
  }

  pixy.changeProg("line");
  res = pixy.line.getMainFeatures();
 
  if (res<=0) 
  {
    // use line data...
  }
}

Hope this helps!

Edward

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