Motors backwards or code backwards?

Hi all, I’m finally starting to program my 3pi. I uploaded the “Line following” code onto my 3pi and when it calibrates it goes straight back and forth instead of left/right. I fixed the code to say:

if(counter < 20 || counter >= 60)

Instead of:

if(counter < 20 || counter >= 60)

That fixed the problem for the calibration, but then after it got going to follow the black line. It just went in a circle, so I played with the code again and let: set_motors(100,-100) for a straight line. It’s working fine now, but why does this seem backwards?

Thanks for any help.


Can you simplify your code down the a program that just drives the motors forward and does not do anything else? Does set_motors(50,50) run both motors forward in this case?

- Ryan

Hi Ryan,

set_motors(50, -50) would run the motors forward.

Sorry, it sounds like your motor was accidentally installed in the wrong orientation and slipped through our tests. There are a couple of possible solutions: you can write a wrapper function that inverts the values of set_motors. Something like:

   void my_set_motors(int m1Speed, int m2Speed)

Another option would be to redefine set_motors in the AVR library and recompile it.

Could you please post the serial number of your 3pi so we can investigate its manufacturing history?

- Ryan

Serial # 0J7445 on the bottom of 3pi.

Thanks, I’ll play around with it and see if that does the trick.