#include <Servo.h>
#define FrontLeftArmFORWARD 125 //front
#define FrontLeftArmNEUTRAL 100
#define FrontLeftArmBACKWARD 75
#define FrontLeftLegUP 70 //up
#define FrontLeftLegNEUTRAL 90
#define FrontLeftLegDOWN 100
#define RearLeftArmFORWARD 125 //front
#define RearLeftArmNEUTRAL 100
#define RearLeftArmBACKWARD 75
#define RearLeftLegUP 70 //up
#define RearLeftLegNEUTRAL 90
#define RearLeftLegDOWN 100
#define FrontRightArmFORWARD 55 //front
#define FrontRightArmNEUTRAL 80
#define FrontRightArmBACKWARD 105
#define FrontRightLegUP 110 //up
#define FrontRightLegNEUTRAL 90
#define FrontRightLegDOWN 80
#define RearRightArmFORWARD 55 //front
#define RearRightArmNEUTRAL 80
#define RearRightArmBACKWARD 105
#define RearRightLegUP 110 //up
#define RearRightLegNEUTRAL 90
#define RearRightLegDOWN 80
#define MyDELAY 500
Servo FrontLeftArm, FrontLeftLeg, RearLeftArm, RearLeftLeg;
Servo FrontRightArm, RearRightArm, FrontRightLeg, RearRightLeg;
void initSpider()
{
FrontRightArm.write(FrontRightArmNEUTRAL);
FrontLeftArm.write(FrontLeftArmNEUTRAL);
RearRightArm.write(RearRightArmNEUTRAL);
RearLeftArm.write(RearLeftLegNEUTRAL);
FrontRightLeg.write(FrontRightLegNEUTRAL);
FrontLeftLeg.write(FrontLeftLegNEUTRAL);
RearRightLeg.write(RearRightLegNEUTRAL);
RearLeftLeg.write(RearLeftLegNEUTRAL);
}
void setup()
{
FrontLeftArm.attach(2); // attaches the servo on pin 5 to the servo object
FrontLeftLeg.attach(3); // attaches the servo on pin 6 to the servo object
RearLeftArm.attach(4); // attaches the servo on pin 9 to the servo object
RearLeftLeg.attach(5); // attaches the servo on pin 10 to the servo object
FrontRightArm.attach(6); // attaches the servo on pin 3 to the servo object
FrontRightLeg.attach(7); // attaches the servo on pin 4 to the servo object
RearRightArm.attach(8); // attaches the servo on pin 8 to the servo object
RearRightLeg.attach(9); // attaches the servo on pin 7 to the servo object
initSpider();
Serial.begin(9600);
Serial.println(“ArduSpider 1.08”);
}
void DDnoge (int visina)
{
// FrontRightLeg.write(90+visina);
// RearLeftLeg.write(90-visina);
}
void DDrame (int naprej)
{
// FrontRightArm.write(90+naprej);
// RearLeftArm.write(90-naprej);
}
void LDnoge (int visina)
{
// FrontLeftLeg.write(90+visina);
// RearRightLeg.write(90-visina);
}
void LDrame (int naprej)
{
// FrontLeftArm.write(90+naprej);
// RearRightArm.write(90-naprej);
}
void tmploop()
{
LDnoge(45);
delay(250);
LDrame(25);
delay(100);
LDnoge(0);
delay(250);
DDnoge(10);
LDrame(-25);
delay(100);
DDnoge(45);
delay(250);
DDrame(25);
delay(100);
DDnoge(0);
delay(250);
LDnoge(10);
DDrame(-25);
delay(100);
}
void loop()
{
Serial.println(“arm f”);
FrontLeftArm.write(FrontLeftArmFORWARD);
RearLeftArm.write(RearLeftArmFORWARD);
FrontRightArm.write(FrontRightArmFORWARD);
RearRightArm.write(RearRightArmFORWARD);
delay(MyDELAY);
Serial.println(“leg d”);
FrontLeftLeg.write(FrontLeftLegDOWN);
RearLeftLeg.write(RearLeftLegDOWN);
FrontRightLeg.write(FrontRightLegDOWN);
RearRightLeg.write(RearRightLegDOWN);
delay(MyDELAY);
Serial.println(“arm b”);
FrontLeftArm.write(FrontLeftArmBACKWARD);
RearLeftArm.write(RearLeftArmBACKWARD);
FrontRightArm.write(FrontRightArmBACKWARD);
RearRightArm.write(RearRightArmBACKWARD);
delay(MyDELAY);
Serial.println(“leg u”);
FrontLeftLeg.write(FrontLeftLegUP);
RearLeftLeg.write(RearLeftLegUP);
FrontRightLeg.write(FrontRightLegUP);
RearRightLeg.write(RearRightLegUP);
delay(MyDELAY);
}