Documente Academic
Documente Profesional
Documente Cultură
// Define servos
Servo FLHservo;
Servo FRHservo;
Servo RLHservo;
Servo RRHservo;
Servo FLKservo;
Servo FRKservo;
Servo RLKservo;
Servo RRKservo;
void setup()
{
// Attach servos (digitally)
FLHservo.attach(FLHpin);
FRHservo.attach(FRHpin);
RLHservo.attach(RLHpin);
RRHservo.attach(RRHpin);
FLKservo.attach(FLKpin);
FRKservo.attach(FRKpin);
RLKservo.attach(RLKpin);
RRKservo.attach(RRKpin);
Serial.begin(9600);
// Center servos
FLHservo.writeMicroseconds(FLHcenter);
FRHservo.writeMicroseconds(FRHcenter);
RLHservo.writeMicroseconds(RLHcenter);
RRHservo.writeMicroseconds(RRHcenter);
FLKservo.writeMicroseconds(FLKcenter+700);
FRKservo.writeMicroseconds(FRKcenter+700);
RLKservo.writeMicroseconds(RLKcenter+700);
RRKservo.writeMicroseconds(RRKcenter+700);
delay(500);
void loop() {
Serial.println("Ready to accept command");
while (!Serial.available()); // stay here so long as COM port is empty
INBYTE = Serial.read(); // read next available byte
delay(50);
void Run()
{
FRKservo.writeMicroseconds(FRKcenter+Raise); // raise front right leg
RLKservo.writeMicroseconds(RLKcenter+Raise-10); // raise rear left leg
FLHservo.writeMicroseconds(FLHcenter+LShift); // move front left leg
backward
RRHservo.writeMicroseconds(RRHcenter-RShift); // move rear right leg
backward
delay(Time/2);
FRHservo.writeMicroseconds(FRHcenter+RShift); // move front right leg
forward
RLHservo.writeMicroseconds(RLHcenter-LShift); // move rear left leg
forward
delay(Time);
FRKservo.writeMicroseconds(FRKcenter); // lower front right leg
RLKservo.writeMicroseconds(RLKcenter); // lower rear left leg
delay(Time);