#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
#include <AFMotor.h>
AF_DCMotor motor(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
motor.setSpeed(200); // set the speed to 200/255
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
}
void loop() {
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(180); // tell servo to go to position in variable 'pos'
delay(1500); // waits 15ms for the servo to reach the position
delay(4000); //stay in this position 4 sec.
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
myservo.write(0); // tell servo to go to position in variable 'pos'
delay(1500); // waits 15ms for the servo to reach the position
Serial.print("tick");
motor.run(FORWARD); // turn it on going forward
delay(3000);
Serial.print("tack");
motor.run(RELEASE); // stopped
delay(5000);
}