Introduction: Pixy2Bot Object Follower (Servo Code)

Building a simple object following robot (no pan/tilt mechanism) with an Arduino Uno + Motor Shield, two cheap continuous servos and a Pixy2.


Step 1: Shopping List

1 Arduino Uno (original or compatible board)

1 Arduino Uno Motor Shield (orginal or compatible)

2 Continuous Servos (eg. Feetech Micro Servo)

1 Pixy2

1 6V Battery pack (eg. 1000 mAh LiPo, 7.4V + LiPo saver)

1 On/Off switch

2 Lego wheels (eg Steering Pulley 373602 3736)

2 Tires (3/4 O-rings fit well on the wheels)

1 Ball Caster

Some Jumper wires

Something where you can mount all the stuff on (eg. Lego + some custom 3D printed parts)

Step 2: Connect Battery, Servos and Pixy2 to Arduino Uno/Motor Shield Etc.

1) Connect Pixy2 to the Arduino Uno & mount Shield on Arduino

2) Attach lego wheels to servos (see picture), mount parts on framework

3) Connect right servo to Pin Out 5 and left servo to Pin Out 6 (see picture)

Attention: sometimes servo pins and socket pins (Out 5 and Out 6) are in a different order. Use a multimeter to find out the order of the GND, 5V and signal pins on the sockets.

You might need some more jumper wires in case the order is not matching.

4) Attach some kind of on/off switch and, if using a LiPo battrey, a LiPo saver to your battery

5) Connect the battery to the motor shield

Step 3: Set Up Your Pixy2 With PixyMon

Step 4: Get the Code...



If you encounter problems while compiling the code (and I'm afraid you will), take a look here:

You will have to go to the Pixy2 library folder and declare some variables in the Pixy2CCC.h file.

You will also have to change Serial1 to Serial in the Pixy2UART.h file.