Dependencies: Motor Servo mbed
Revision 0:328a246ec698, committed 2015-10-14
- Comitter:
- w00Gyy
- Date:
- Wed Oct 14 03:27:27 2015 +0000
- Commit message:
- Actuator Lab Part 2;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor.lib Wed Oct 14 03:27:27 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Motor/#f265e441bcd9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Wed Oct 14 03:27:27 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/simon/code/Servo/#36b69a7ced07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 14 03:27:27 2015 +0000 @@ -0,0 +1,33 @@ +/* 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) + } + + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 14 03:27:27 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file