![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Project for 380
main.cpp
- Committer:
- b28nguye
- Date:
- 2019-09-27
- Revision:
- 0:110dc3bbf9c1
- Child:
- 1:679934743c5e
File content as of revision 0:110dc3bbf9c1:
// 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; } }