Wednesday, November 27, 2013

// This is the code Chris used to move his carrage
#include <Servo.h>
Servo myservo;
void setup()
{
myservo.attach(5); // Attaches the servo to pin 5
}
void loop()
{
myservo.write(0); // When a cont. Servo is assigned the value 0
// it will move to the left at max speed
delay(2100);
myservo.write(90); // 90 will stop a continuous motor
delay(3000);
myservo.write(180); // 180 will move a cont. Servo to the right
delay(1900);
myservo.write(90);
delay(3000);
}
view raw gistfile1.txt hosted with ❤ by GitHub
This code is similar to the one in an earlier post, but the speed of the motor was more controlled. If you scroll down to the video of the motor and legos titled "Main mechanism!", this is the code used for it to slide left and right.

No comments:

Post a Comment