Ivelin Kozarev / Mbed 2 deprecated TDP_main_fork

Dependencies:   LocalPositionSystem MMA8451Q Motor_Driver Sensors mbed

Fork of TDP_main by Yelfie

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers shooter.h Source File

shooter.h

00001 /*
00002 Header file for Shooting mechanism.
00003  
00004 Takes dutyCycle as a float and converts it t oduty cycle.
00005 When off- dutyCycle is just switched to 0 duty cycle.
00006 
00007 IMPORTANT: need to convert back to dutycycle=0, when not used!! 
00008 
00009 Possible improvements:
00010 -Convert program so when it's off the pins are completely off???  
00011 -Caclutalate better time for the waits???
00012 -maybe change the period??
00013 
00014 TESTED AND WORKING - 06/03
00015 IK
00016 */
00017 
00018 #ifndef _SHOOTER_H
00019 #define _SHOOTER_H
00020 
00021 PwmOut squareOut(PTE31); //TESTED WORKING
00022 DigitalOut solenoid(PTA17);
00023 
00024 void shoot(float dutyCycle) {
00025     
00026     squareOut.period(0.01f);  // 0.01 second period
00027     squareOut.write(dutyCycle);  // 50% duty cycle
00028     wait(1.7); // give time for motors to reach optimal speed - is it needed 
00029     
00030     if (dutyCycle == 0.0) //if not used any more, don't shoot
00031         return;
00032     
00033     solenoid = 1; //push solenoid
00034     wait (0.3); // wait needed
00035     solenoid = 0;   //pull it back
00036      
00037     return;   
00038 }
00039 
00040 #endif