Dependencies: Motor Servo mbed
main.cpp
- Committer:
- w00Gyy
- Date:
- 2015-10-14
- Revision:
- 0:328a246ec698
File content as of revision 0:328a246ec698:
/* Actuator Lab Part 2 This program demonstrates the simultanious action of 2 servo motors. The servos rotate opposite to eachother and once they reach their maximum angle of rotation, they return to the original location. Written by MIDN 3/C C. Garcia, 13-OCT-15 */ #include "mbed.h" #include "Servo.h" Servo myservo(p21); //Servo Pins Servo myservo1(p22); int MaxDegrees = 180; //Max rotation float PW = .0018; //Pulsewidth int main() { float Position = 0.0; //initial position myservo.calibrate(PW/2, MaxDegrees/2); //servo calibration myservo1.calibrate(PW/2, MaxDegrees/2); while(1) { for(Position = 0; Position <= 1; Position += .05556) { //incriments from 0 to 1 by 10 degrees myservo = Position; myservo1 = 1 - Position; //reverses direction of rotation for the second servo getchar(); //proceeds to the next incriment of the for loop once character is recieved (fancy wait) } } }