a
Dependencies: mbed
Fork of Turrett_Project by
Revision 1:c9b199994bc2, committed 2016-03-01
- Comitter:
- taylormooers
- Date:
- Tue Mar 01 16:14:07 2016 +0000
- Parent:
- 0:d9acaeb37aed
- Commit message:
- Function to fire shots
Changed in this revision
Nerf_function.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Nerf_function.h Tue Mar 01 16:14:07 2016 +0000 @@ -0,0 +1,14 @@ +void fire_shots(PinName trigger_pin,PinName spinner_pin, int shots) +{ DigitalOut trigger(trigger_pin); + DigitalOut spinner(spinner_pin); + + spinner = 1; + wait(3.0); + + trigger = 1; + wait((float)shots*0.35); + + trigger = 0; + spinner = 0; + wait(3.0); +}
--- a/main.cpp Thu Feb 25 15:18:34 2016 +0000 +++ b/main.cpp Tue Mar 01 16:14:07 2016 +0000 @@ -1,27 +1,14 @@ #include "mbed.h" +#include "Nerf_function.h" -DigitalOut spinnerled(LED1); -DigitalOut triggerled(LED2); -DigitalOut spinner(p20); -DigitalOut trigger(p19); -int i=0; -int shots; +PinName spinner(p20); +PinName trigger(p19); + int main() -{ - //while(1) { - spinnerled = 1; - spinner=1; - shots = 3.0; - while(i<shots) - { - trigger = 1; - triggerled=1; - wait(0.75); - trigger=0; - triggerled=0; - wait(0.5); - i=i+1; - } - i=0; - - } +{ int shots = 3; + + fire_shots(trigger,spinner,shots); // Source code is in Nerf_function.h + + while(1); +} +