4. Attaching the legs to the servo
Before you attach the legs to the servos please make sure your servos are centered. To do this,
please connect all three servos to the digital pins D9, D10 and D11 (see more details below) of the
Beetle shield and upload the following program to the Beetle. The file name is
insect_bot_servo_center.ino
and available on the product/Wiki website at DFRobot.com
#include <Servo.h>
// creating the servo objects for front, rear and mid servo
Servo frontLeg;
Servo rearLeg;
Servo midLeg;
// setting the servo angle to 90° for startup
byte frontAngle = 90;
byte rearAngle = 90;
byte midAngle = 90;
// Setup function
void setup(){
frontLeg.attach(9);
rearLeg.attach(10);
midLeg.attach(11);
// move servos to center position -> 90°
frontLeg.write(frontAngle);
rearLeg.write(rearAngle);
midLeg.write(midAngle);
delay(2000);
}
// The loop remains empty
void loop(){
}
Put the legs with the servo horn on the servo shaft and secure them with the provided screw.