<< return to Pixycam.com

I'll ask you about the intersection coding

Hello, after a short stop at the intersection, I want to get 1 on the Bluetooth receiver and move to the left and 2 on the right.
How do I code?

my code

if (pixy.line.vectors->m_flags&LINE_FLAG_INTERSECTION_PRESENT)
  {

pixy.line.setMode(LINE_MODE_TURN_DELAYED);
}
else // otherwise, pedal to the metal!
{
left += ZUMO_FAST;
right += ZUMO_FAST;
}
}

motors.setLeftSpeed(left);
motors.setRightSpeed(right);

  if (res&LINE_INTERSECTION)  

{
{pixy.line.setMode(LINE_MODE_TURN_DELAYED);}
if (code == ‘3’) {pixy.line.setNextTurn(45);} // blue 90 degrees is a left turn
else if (code == ‘1’) {pixy.line.setNextTurn(-45);} // red -90 is a right turn
else if (code == ‘2’) {pixy.line.setNextTurn(0); } // green 0 is a stat

}
}
}

This code does not implement the system that I want to implement.

Hello,
I don’t fully understand what your code is trying to do, and I don’t fully understand your question. (sorry)
I’m not sure how you’ve integrated bluetooth – is this where the ‘code’ variable is set?

If so, I would guess that something like this would work

if (code == ‘1’) {pixy.line.setNextTurn(90);} // 1, turn left
else if (code == ‘2’) {pixy.line.setNextTurn(-90); 2, turn right

I would tend to call

pixy.line.setMode(LINE_MODE_TURN_DELAYED);

once at the top of the program. (once it’s set, it will stay set.)

Edward

1 Like