Bat Ear Code
/
multiServoBat
a program
Fork of multiServoBat by
Diff: main.cpp
- Revision:
- 2:7e5d670ed9aa
- Parent:
- 1:829cbbaeaf32
- Child:
- 3:88de581de68d
--- a/main.cpp Wed Jul 31 19:33:40 2019 +0000 +++ b/main.cpp Thu Aug 01 14:40:15 2019 +0000 @@ -6,9 +6,8 @@ float range = 0.0005; float degrees = 45.0; - - void together(); +void apart(int side); int main() { printf("Hello bats!\n"); @@ -17,26 +16,31 @@ while(1) { printf("entering together() call\n"); together(); - //wait(10); - //apart1(servoPtr); + wait(5); + apart(0); + wait(2); + apart(1); + wait(2); } } - - - - - - - - void together() { float i; int j; + float max = 1.0, min = 0.0, incr = 0.01; - for(i = 0.0; i<1.00; i+=0.01) + for(i = min; i<max; i+=incr) + { + for(j = 0; j<NUM_SERVOS; j++) + { + servo[j] = i; + } + wait(0.01); + } + wait(1); + for(i = max; i>min; i-=incr) { for(j = 0; j<NUM_SERVOS; j++) { @@ -44,44 +48,41 @@ } wait(0.01); } - wait(5); - for(i = 1.0; i>0.00; i-=0.01) + wait(1); + printf("finished one of together\n"); +} + +//only moves two of the servo motors, which 2 depends on the parameter side: runs 1 and 3 when side = 1, runs 2 and 4 when side = 0 +void apart (int side) +{ + float i; + int j; + float max = 1.0, min = 0.0, incr = 0.01; + for(i = min; i<max; i+=incr) { for(j = 0; j<NUM_SERVOS; j++) { - servo[j] = i; - } - wait(0.01); - } - printf("finished one of together\n"); -} - -/*void apart1 (Servo * servoPtr) -{ - int i,j; - for(i = 0.0; i<1.00; i+=0.01) - { - for(j = 0; j<numServos; j++) - { - if(j%1 == 0) + if(j%2 == side) { - servoPtr[j] = i; + servo[j] = i; } } wait(0.01); } - wait(5); - for(i = 1.0; i>0.00; i-=0.01) + wait(1); + for(i = max; i>min; i-=incr) { - if(j%1 == 0) + for(j = 0; j<NUM_SERVOS; j++) { - servoPtr[j] = i; + if(j%2 == side) + { + servo[j] = i; + } } - wait(0.01); } + wait(1); printf("finished one of together\n"); -} -*/ \ No newline at end of file +} \ No newline at end of file