Bobby Nguyen
/
MTE380
Project for 380
Diff: main.cpp
- Revision:
- 0:110dc3bbf9c1
- Child:
- 1:679934743c5e
diff -r 000000000000 -r 110dc3bbf9c1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 27 15:21:03 2019 +0000 @@ -0,0 +1,56 @@ +// Continuously sweep the servo through it's full range +#include "mbed.h" +#include "Servo.h" + +Servo servo_1(D3); +Servo servo_2(D5); +Servo servo_3(D6); +Servo servo_4(D9); +Servo servo_5(D10); +Servo servo_6(D11); + + +void test_write(Servo servo_ID){ + while(1) { + wait(1.0); + + for(int i=0; i<100; i++) { //adjust range + servo_ID = i/100.0; //adjust speed + wait(0.01); + } + wait(1.0); + + for(int i=100; i>0; i--) { + servo_ID = i/100.0; + wait(0.01); + } + } +} + +void test_position(Servo servo_ID){ + int y =0; + while(1){ + y +=1; + printf("Test %d ", y); + for (int i=-90; i<=90; i+=45){ + servo_ID.position(i); + servo_2.position(i); + //servo_3.position(i); + wait(1); + //printf("Angle %d", i); + //wait(1); + } + } +} + +int main() { + printf ("test start"); + wait(1.0); + //test_write(servo_1); + test_position(servo_1); + int x = 0; + while (1){ + printf ("Test %d ", x); + x +=1; + } +} \ No newline at end of file