ese519
/
servo_test
aa
Revision 0:cbf3d33db709, committed 2015-10-16
- Comitter:
- jfields
- Date:
- Fri Oct 16 17:17:41 2015 +0000
- Commit message:
- serv
Changed in this revision
diff -r 000000000000 -r cbf3d33db709 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Oct 16 17:17:41 2015 +0000 @@ -0,0 +1,49 @@ +#include "mbed.h" +#include "rtos.h" + +PwmOut servo1(p25); +PwmOut servo2(p24); + +// Threads +void bpc_func(void const *args); +Thread * bpc_thread; + +float dty_servo_open = 0.1125; // PCT [3.75-11.25] +float dty_servo_close = 0.0375; // PCT [3.75-11.25] +float period = 0.02; // sec + +AnalogIn Button(p15); // elevator button press Voltage = 3.3*0.2*n ; n = Floor Number + + +int main() { + + servo1.period(period); + servo2.period(period); + bpc_thread = new Thread(bpc_func); // start button checker thread + + + while(1) { + + } +} + +void bpc_func(void const *args) { + while (1) { + float ADC_val = Button.read(); + int val = ADC_val*10; + if(val == 2) { + // blah + } else if(val == 4) { + // blah + } else if(val == 6) { + // blah + } else if(val == 8) { + servo1.write(dty_servo_open); + servo2.write(dty_servo_open); + } else if(val == 10) { + servo1.write(dty_servo_close); + servo2.write(dty_servo_close); + } + wait(0.1); + } +}
diff -r 000000000000 -r cbf3d33db709 mbed-rtos.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Fri Oct 16 17:17:41 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#12552ef4e980
diff -r 000000000000 -r cbf3d33db709 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Oct 16 17:17:41 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68 \ No newline at end of file